@@ -14,176 +14,176 @@ |
||
| 14 | 14 | class EEH_Maps |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - // array of map settings |
|
| 18 | - public static $gmap_vars = array(); |
|
| 19 | - |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * google_map - creates a Google Map Link |
|
| 23 | - * |
|
| 24 | - * @param array $ee_gmaps_opts array of attributes required for the map link generation |
|
| 25 | - * @return string (link to map!) |
|
| 26 | - */ |
|
| 27 | - public static function google_map($ee_gmaps_opts) |
|
| 28 | - { |
|
| 29 | - |
|
| 30 | - $ee_map_width = ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
| 31 | - $ee_map_height = ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
| 32 | - $ee_map_zoom = ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
| 33 | - $ee_map_nav_display = ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
| 34 | - $ee_map_nav_size = ! empty($ee_gmaps_opts['ee_map_nav_size']) |
|
| 35 | - ? $ee_gmaps_opts['ee_map_nav_size'] |
|
| 36 | - : 'default'; |
|
| 37 | - $ee_map_type_control = ! empty($ee_gmaps_opts['ee_map_type_control']) |
|
| 38 | - ? $ee_gmaps_opts['ee_map_type_control'] |
|
| 39 | - : 'default'; |
|
| 40 | - $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
|
| 41 | - |
|
| 42 | - if (! empty($ee_gmaps_opts['ee_map_align'])) { |
|
| 43 | - switch ($ee_gmaps_opts['ee_map_align']) { |
|
| 44 | - case "left": |
|
| 45 | - $map_align = 'ee-gmap-align-left left'; |
|
| 46 | - break; |
|
| 47 | - case "right": |
|
| 48 | - $map_align = 'ee-gmap-align-right right'; |
|
| 49 | - break; |
|
| 50 | - case "center": |
|
| 51 | - $map_align = 'ee-gmap-align-center center'; |
|
| 52 | - break; |
|
| 53 | - case "none": |
|
| 54 | - default: |
|
| 55 | - $map_align = 'ee-gmap-align-none'; |
|
| 56 | - } |
|
| 57 | - } else { |
|
| 58 | - $map_align = 'ee-gmap-align-none'; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - // Determine whether user has set a hardoded url to use and |
|
| 63 | - // if so display a Google static iframe map else run V3 api |
|
| 64 | - if ($static_url) { |
|
| 65 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
| 66 | - $html .= '<iframe src="' . $static_url . '&output=embed"' |
|
| 67 | - . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
|
| 68 | - . ' frameborder="0" scrolling="no">'; |
|
| 69 | - $html .= '</iframe>'; |
|
| 70 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
| 71 | - $html .= '</div>'; |
|
| 72 | - return $html; |
|
| 73 | - |
|
| 74 | - } else { |
|
| 75 | - EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
| 76 | - 'map_ID' => $ee_gmaps_opts['map_ID'], |
|
| 77 | - 'ee_map_zoom' => $ee_map_zoom, |
|
| 78 | - 'ee_map_nav_display' => $ee_map_nav_display, |
|
| 79 | - 'ee_map_nav_size' => $ee_map_nav_size, |
|
| 80 | - 'ee_map_type_control' => $ee_map_type_control, |
|
| 81 | - 'location' => $ee_gmaps_opts['location'], |
|
| 82 | - ); |
|
| 83 | - |
|
| 84 | - $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
|
| 85 | - $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
|
| 86 | - . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
|
| 87 | - . ' style="' . $style . '"></div>' |
|
| 88 | - . '</div>'; |
|
| 89 | - |
|
| 90 | - wp_enqueue_script('gmap_api'); |
|
| 91 | - wp_enqueue_script('ee_gmap'); |
|
| 92 | - add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
| 93 | - |
|
| 94 | - return $html; |
|
| 95 | - } // end auto map or static url map check |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * enqueue_script |
|
| 101 | - * |
|
| 102 | - * @return void |
|
| 103 | - */ |
|
| 104 | - public static function footer_enqueue_script() |
|
| 105 | - { |
|
| 106 | - wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * registers scripts for maps |
|
| 112 | - */ |
|
| 113 | - public static function espresso_google_map_js() |
|
| 114 | - { |
|
| 115 | - $api_url = sprintf( |
|
| 116 | - "https://maps.googleapis.com/maps/api/js?key=%s", |
|
| 117 | - apply_filters( |
|
| 118 | - 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', |
|
| 119 | - EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
| 120 | - ) |
|
| 121 | - ); |
|
| 122 | - wp_register_script('gmap_api', $api_url, array('jquery'), null, true); |
|
| 123 | - wp_register_script('ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * creates a Google Map Link |
|
| 128 | - * |
|
| 129 | - * @param array $atts array of attributes required for the map link generation |
|
| 130 | - * @return string (link to map!) |
|
| 131 | - */ |
|
| 132 | - public static function google_map_link($atts) |
|
| 133 | - { |
|
| 134 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 135 | - extract($atts); |
|
| 136 | - /** @var string $address */ |
|
| 137 | - /** @var string $city */ |
|
| 138 | - /** @var string $state */ |
|
| 139 | - /** @var string $zip */ |
|
| 140 | - /** @var string $country */ |
|
| 141 | - $address = "{$address}"; |
|
| 142 | - $city = "{$city}"; |
|
| 143 | - $state = "{$state}"; |
|
| 144 | - $zip = "{$zip}"; |
|
| 145 | - $country = "{$country}"; |
|
| 146 | - $text = isset($text) ? "{$text}" : ""; |
|
| 147 | - $type = isset($type) ? "{$type}" : ""; |
|
| 148 | - $map_w = isset($map_w) ? "{$map_w}" : 400; |
|
| 149 | - $map_h = isset($map_h) ? "{$map_h}" : 400; |
|
| 150 | - $id = isset($id) ? $id : 'not_set'; |
|
| 151 | - $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
|
| 152 | - |
|
| 153 | - $address_string = ($address != '' ? $address : '') |
|
| 154 | - . ($city != '' ? ',' . $city : '') |
|
| 155 | - . ($state != '' ? ',' . $state : '') |
|
| 156 | - . ($zip != '' ? ',' . $zip : '') |
|
| 157 | - . ($country != '' ? ',' . $country : ''); |
|
| 158 | - |
|
| 159 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($address_string)); |
|
| 160 | - |
|
| 161 | - switch ($type) { |
|
| 162 | - case 'text': |
|
| 163 | - default: |
|
| 164 | - $text = $text == '' ? __('Map and Directions', 'event_espresso') : $text; |
|
| 165 | - break; |
|
| 166 | - |
|
| 167 | - case 'url_only': |
|
| 168 | - case 'url': |
|
| 169 | - $text = $google_map; |
|
| 170 | - break; |
|
| 171 | - |
|
| 172 | - case 'map': |
|
| 173 | - $scheme = is_ssl() ? 'https://' : 'http://'; |
|
| 174 | - |
|
| 175 | - $api_key = apply_filters( |
|
| 176 | - 'FHEE__EEH_Maps__espresso_google_maps_link__api_key', |
|
| 177 | - EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
| 178 | - ); |
|
| 179 | - |
|
| 180 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2($scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address_string) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($address_string) . '&sensor=false&key=' . $api_key) . '" /></a>'; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - return $type === 'url_only' |
|
| 184 | - ? $text |
|
| 185 | - : '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
| 186 | - } |
|
| 17 | + // array of map settings |
|
| 18 | + public static $gmap_vars = array(); |
|
| 19 | + |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * google_map - creates a Google Map Link |
|
| 23 | + * |
|
| 24 | + * @param array $ee_gmaps_opts array of attributes required for the map link generation |
|
| 25 | + * @return string (link to map!) |
|
| 26 | + */ |
|
| 27 | + public static function google_map($ee_gmaps_opts) |
|
| 28 | + { |
|
| 29 | + |
|
| 30 | + $ee_map_width = ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
| 31 | + $ee_map_height = ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
| 32 | + $ee_map_zoom = ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
| 33 | + $ee_map_nav_display = ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
| 34 | + $ee_map_nav_size = ! empty($ee_gmaps_opts['ee_map_nav_size']) |
|
| 35 | + ? $ee_gmaps_opts['ee_map_nav_size'] |
|
| 36 | + : 'default'; |
|
| 37 | + $ee_map_type_control = ! empty($ee_gmaps_opts['ee_map_type_control']) |
|
| 38 | + ? $ee_gmaps_opts['ee_map_type_control'] |
|
| 39 | + : 'default'; |
|
| 40 | + $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
|
| 41 | + |
|
| 42 | + if (! empty($ee_gmaps_opts['ee_map_align'])) { |
|
| 43 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
| 44 | + case "left": |
|
| 45 | + $map_align = 'ee-gmap-align-left left'; |
|
| 46 | + break; |
|
| 47 | + case "right": |
|
| 48 | + $map_align = 'ee-gmap-align-right right'; |
|
| 49 | + break; |
|
| 50 | + case "center": |
|
| 51 | + $map_align = 'ee-gmap-align-center center'; |
|
| 52 | + break; |
|
| 53 | + case "none": |
|
| 54 | + default: |
|
| 55 | + $map_align = 'ee-gmap-align-none'; |
|
| 56 | + } |
|
| 57 | + } else { |
|
| 58 | + $map_align = 'ee-gmap-align-none'; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + // Determine whether user has set a hardoded url to use and |
|
| 63 | + // if so display a Google static iframe map else run V3 api |
|
| 64 | + if ($static_url) { |
|
| 65 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
| 66 | + $html .= '<iframe src="' . $static_url . '&output=embed"' |
|
| 67 | + . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
|
| 68 | + . ' frameborder="0" scrolling="no">'; |
|
| 69 | + $html .= '</iframe>'; |
|
| 70 | + $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
| 71 | + $html .= '</div>'; |
|
| 72 | + return $html; |
|
| 73 | + |
|
| 74 | + } else { |
|
| 75 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
| 76 | + 'map_ID' => $ee_gmaps_opts['map_ID'], |
|
| 77 | + 'ee_map_zoom' => $ee_map_zoom, |
|
| 78 | + 'ee_map_nav_display' => $ee_map_nav_display, |
|
| 79 | + 'ee_map_nav_size' => $ee_map_nav_size, |
|
| 80 | + 'ee_map_type_control' => $ee_map_type_control, |
|
| 81 | + 'location' => $ee_gmaps_opts['location'], |
|
| 82 | + ); |
|
| 83 | + |
|
| 84 | + $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
|
| 85 | + $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
|
| 86 | + . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
|
| 87 | + . ' style="' . $style . '"></div>' |
|
| 88 | + . '</div>'; |
|
| 89 | + |
|
| 90 | + wp_enqueue_script('gmap_api'); |
|
| 91 | + wp_enqueue_script('ee_gmap'); |
|
| 92 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
| 93 | + |
|
| 94 | + return $html; |
|
| 95 | + } // end auto map or static url map check |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * enqueue_script |
|
| 101 | + * |
|
| 102 | + * @return void |
|
| 103 | + */ |
|
| 104 | + public static function footer_enqueue_script() |
|
| 105 | + { |
|
| 106 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * registers scripts for maps |
|
| 112 | + */ |
|
| 113 | + public static function espresso_google_map_js() |
|
| 114 | + { |
|
| 115 | + $api_url = sprintf( |
|
| 116 | + "https://maps.googleapis.com/maps/api/js?key=%s", |
|
| 117 | + apply_filters( |
|
| 118 | + 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', |
|
| 119 | + EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
| 120 | + ) |
|
| 121 | + ); |
|
| 122 | + wp_register_script('gmap_api', $api_url, array('jquery'), null, true); |
|
| 123 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * creates a Google Map Link |
|
| 128 | + * |
|
| 129 | + * @param array $atts array of attributes required for the map link generation |
|
| 130 | + * @return string (link to map!) |
|
| 131 | + */ |
|
| 132 | + public static function google_map_link($atts) |
|
| 133 | + { |
|
| 134 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 135 | + extract($atts); |
|
| 136 | + /** @var string $address */ |
|
| 137 | + /** @var string $city */ |
|
| 138 | + /** @var string $state */ |
|
| 139 | + /** @var string $zip */ |
|
| 140 | + /** @var string $country */ |
|
| 141 | + $address = "{$address}"; |
|
| 142 | + $city = "{$city}"; |
|
| 143 | + $state = "{$state}"; |
|
| 144 | + $zip = "{$zip}"; |
|
| 145 | + $country = "{$country}"; |
|
| 146 | + $text = isset($text) ? "{$text}" : ""; |
|
| 147 | + $type = isset($type) ? "{$type}" : ""; |
|
| 148 | + $map_w = isset($map_w) ? "{$map_w}" : 400; |
|
| 149 | + $map_h = isset($map_h) ? "{$map_h}" : 400; |
|
| 150 | + $id = isset($id) ? $id : 'not_set'; |
|
| 151 | + $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
|
| 152 | + |
|
| 153 | + $address_string = ($address != '' ? $address : '') |
|
| 154 | + . ($city != '' ? ',' . $city : '') |
|
| 155 | + . ($state != '' ? ',' . $state : '') |
|
| 156 | + . ($zip != '' ? ',' . $zip : '') |
|
| 157 | + . ($country != '' ? ',' . $country : ''); |
|
| 158 | + |
|
| 159 | + $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($address_string)); |
|
| 160 | + |
|
| 161 | + switch ($type) { |
|
| 162 | + case 'text': |
|
| 163 | + default: |
|
| 164 | + $text = $text == '' ? __('Map and Directions', 'event_espresso') : $text; |
|
| 165 | + break; |
|
| 166 | + |
|
| 167 | + case 'url_only': |
|
| 168 | + case 'url': |
|
| 169 | + $text = $google_map; |
|
| 170 | + break; |
|
| 171 | + |
|
| 172 | + case 'map': |
|
| 173 | + $scheme = is_ssl() ? 'https://' : 'http://'; |
|
| 174 | + |
|
| 175 | + $api_key = apply_filters( |
|
| 176 | + 'FHEE__EEH_Maps__espresso_google_maps_link__api_key', |
|
| 177 | + EE_Registry::instance()->CFG->map_settings->google_map_api_key |
|
| 178 | + ); |
|
| 179 | + |
|
| 180 | + return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2($scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address_string) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($address_string) . '&sensor=false&key=' . $api_key) . '" /></a>'; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + return $type === 'url_only' |
|
| 184 | + ? $text |
|
| 185 | + : '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
| 186 | + } |
|
| 187 | 187 | } |
| 188 | 188 | // End of file EEH_Maps.helper.php |
| 189 | 189 | // Location: /helpers/EEH_Maps.helper.php |
| 190 | 190 | \ No newline at end of file |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | : 'default'; |
| 40 | 40 | $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
| 41 | 41 | |
| 42 | - if (! empty($ee_gmaps_opts['ee_map_align'])) { |
|
| 42 | + if ( ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
| 43 | 43 | switch ($ee_gmaps_opts['ee_map_align']) { |
| 44 | 44 | case "left": |
| 45 | 45 | $map_align = 'ee-gmap-align-left left'; |
@@ -62,12 +62,12 @@ discard block |
||
| 62 | 62 | // Determine whether user has set a hardoded url to use and |
| 63 | 63 | // if so display a Google static iframe map else run V3 api |
| 64 | 64 | if ($static_url) { |
| 65 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
| 66 | - $html .= '<iframe src="' . $static_url . '&output=embed"' |
|
| 67 | - . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
|
| 65 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
| 66 | + $html .= '<iframe src="'.$static_url.'&output=embed"' |
|
| 67 | + . ' style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"' |
|
| 68 | 68 | . ' frameborder="0" scrolling="no">'; |
| 69 | 69 | $html .= '</iframe>'; |
| 70 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
| 70 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
| 71 | 71 | $html .= '</div>'; |
| 72 | 72 | return $html; |
| 73 | 73 | |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | 'location' => $ee_gmaps_opts['location'], |
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | - $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
|
| 85 | - $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
|
| 86 | - . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
|
| 87 | - . ' style="' . $style . '"></div>' |
|
| 84 | + $style = 'width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;'; |
|
| 85 | + $html = '<div class="ee-gmap-wrapper '.$map_align.'">' |
|
| 86 | + . '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'"' |
|
| 87 | + . ' style="'.$style.'"></div>' |
|
| 88 | 88 | . '</div>'; |
| 89 | 89 | |
| 90 | 90 | wp_enqueue_script('gmap_api'); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | ) |
| 121 | 121 | ); |
| 122 | 122 | wp_register_script('gmap_api', $api_url, array('jquery'), null, true); |
| 123 | - wp_register_script('ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
| 123 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', true); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
| 152 | 152 | |
| 153 | 153 | $address_string = ($address != '' ? $address : '') |
| 154 | - . ($city != '' ? ',' . $city : '') |
|
| 155 | - . ($state != '' ? ',' . $state : '') |
|
| 156 | - . ($zip != '' ? ',' . $zip : '') |
|
| 157 | - . ($country != '' ? ',' . $country : ''); |
|
| 154 | + . ($city != '' ? ','.$city : '') |
|
| 155 | + . ($state != '' ? ','.$state : '') |
|
| 156 | + . ($zip != '' ? ','.$zip : '') |
|
| 157 | + . ($country != '' ? ','.$country : ''); |
|
| 158 | 158 | |
| 159 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($address_string)); |
|
| 159 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
| 160 | 160 | |
| 161 | 161 | switch ($type) { |
| 162 | 162 | case 'text': |
@@ -177,12 +177,12 @@ discard block |
||
| 177 | 177 | EE_Registry::instance()->CFG->map_settings->google_map_api_key |
| 178 | 178 | ); |
| 179 | 179 | |
| 180 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2($scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address_string) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($address_string) . '&sensor=false&key=' . $api_key) . '" /></a>'; |
|
| 180 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false&key='.$api_key).'" /></a>'; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return $type === 'url_only' |
| 184 | 184 | ? $text |
| 185 | - : '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
| 185 | + : '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | // End of file EEH_Maps.helper.php |
@@ -44,77 +44,76 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected $_image_url; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * gateway URL variable |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - protected $_base_gateway_url = ''; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * EEG_Paypal_Express constructor. |
|
| 58 | - */ |
|
| 59 | - public function __construct() |
|
| 60 | - { |
|
| 61 | - $this->_currencies_supported = array( |
|
| 62 | - 'USD', |
|
| 63 | - 'AUD', |
|
| 64 | - 'BRL', |
|
| 65 | - 'CAD', |
|
| 66 | - 'CZK', |
|
| 67 | - 'DKK', |
|
| 68 | - 'EUR', |
|
| 69 | - 'HKD', |
|
| 70 | - 'HUF', |
|
| 71 | - 'ILS', |
|
| 72 | - 'JPY', |
|
| 73 | - 'MYR', |
|
| 74 | - 'MXN', |
|
| 75 | - 'NOK', |
|
| 76 | - 'NZD', |
|
| 77 | - 'PHP', |
|
| 78 | - 'PLN', |
|
| 79 | - 'GBP', |
|
| 80 | - 'RUB', |
|
| 81 | - 'SGD', |
|
| 82 | - 'SEK', |
|
| 83 | - 'CHF', |
|
| 84 | - 'TWD', |
|
| 85 | - 'THB', |
|
| 86 | - 'TRY' |
|
| 87 | - ); |
|
| 88 | - parent::__construct(); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
| 47 | + /** |
|
| 48 | + * gateway URL variable |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + protected $_base_gateway_url = ''; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * EEG_Paypal_Express constructor. |
|
| 58 | + */ |
|
| 59 | + public function __construct() |
|
| 60 | + { |
|
| 61 | + $this->_currencies_supported = array( |
|
| 62 | + 'USD', |
|
| 63 | + 'AUD', |
|
| 64 | + 'BRL', |
|
| 65 | + 'CAD', |
|
| 66 | + 'CZK', |
|
| 67 | + 'DKK', |
|
| 68 | + 'EUR', |
|
| 69 | + 'HKD', |
|
| 70 | + 'HUF', |
|
| 71 | + 'ILS', |
|
| 72 | + 'JPY', |
|
| 73 | + 'MYR', |
|
| 74 | + 'MXN', |
|
| 75 | + 'NOK', |
|
| 76 | + 'NZD', |
|
| 77 | + 'PHP', |
|
| 78 | + 'PLN', |
|
| 79 | + 'GBP', |
|
| 80 | + 'RUB', |
|
| 81 | + 'SGD', |
|
| 82 | + 'SEK', |
|
| 83 | + 'CHF', |
|
| 84 | + 'TWD', |
|
| 85 | + 'THB', |
|
| 86 | + 'TRY' |
|
| 87 | + ); |
|
| 88 | + parent::__construct(); |
|
| 89 | + } |
|
| 90 | + |
|
| 95 | 91 | |
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
| 96 | 95 | * |
| 97 | 96 | *@param array $settings_array |
| 98 | 97 | */ |
| 99 | 98 | public function set_settings( $settings_array ) { |
| 100 | 99 | parent::set_settings($settings_array); |
| 101 | 100 | // Redirect URL. |
| 102 | - $this->_base_gateway_url = $this->_debug_mode |
|
| 103 | - ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
| 104 | - : 'https://api-3t.paypal.com/nvp'; |
|
| 101 | + $this->_base_gateway_url = $this->_debug_mode |
|
| 102 | + ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
| 103 | + : 'https://api-3t.paypal.com/nvp'; |
|
| 105 | 104 | } |
| 106 | 105 | |
| 107 | 106 | |
| 108 | 107 | |
| 109 | - /** |
|
| 110 | - * @param EEI_Payment $payment |
|
| 111 | - * @param array $billing_info |
|
| 112 | - * @param string $return_url |
|
| 113 | - * @param string $notify_url |
|
| 114 | - * @param string $cancel_url |
|
| 115 | - * @return \EE_Payment|\EEI_Payment |
|
| 116 | - * @throws \EE_Error |
|
| 117 | - */ |
|
| 108 | + /** |
|
| 109 | + * @param EEI_Payment $payment |
|
| 110 | + * @param array $billing_info |
|
| 111 | + * @param string $return_url |
|
| 112 | + * @param string $notify_url |
|
| 113 | + * @param string $cancel_url |
|
| 114 | + * @return \EE_Payment|\EEI_Payment |
|
| 115 | + * @throws \EE_Error |
|
| 116 | + */ |
|
| 118 | 117 | public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
| 119 | 118 | if ( ! $payment instanceof EEI_Payment ) { |
| 120 | 119 | $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
@@ -202,9 +201,9 @@ discard block |
||
| 202 | 201 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
| 203 | 202 | // Item quantity. |
| 204 | 203 | $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1; |
| 205 | - // Digital item is sold. |
|
| 206 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
| 207 | - $item_num++; |
|
| 204 | + // Digital item is sold. |
|
| 205 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
| 206 | + $item_num++; |
|
| 208 | 207 | } |
| 209 | 208 | } else { |
| 210 | 209 | // Just one Item. |
@@ -277,7 +276,6 @@ discard block |
||
| 277 | 276 | |
| 278 | 277 | |
| 279 | 278 | /** |
| 280 | - |
|
| 281 | 279 | * @param array $update_info { |
| 282 | 280 | * @type string $gateway_txn_id |
| 283 | 281 | * @type string status an EEMI_Payment status |
@@ -297,8 +295,8 @@ discard block |
||
| 297 | 295 | return $payment; |
| 298 | 296 | } |
| 299 | 297 | $primary_registrant = $transaction->primary_registration(); |
| 300 | - $payment_details = $payment->details(); |
|
| 301 | - // Check if we still have the token. |
|
| 298 | + $payment_details = $payment->details(); |
|
| 299 | + // Check if we still have the token. |
|
| 302 | 300 | if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
| 303 | 301 | $payment->set_status( $this->_pay_model->failed_status() ); |
| 304 | 302 | return $payment; |
@@ -407,35 +405,35 @@ discard block |
||
| 407 | 405 | */ |
| 408 | 406 | public function _ppExpress_check_response( $request_response ) { |
| 409 | 407 | if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
| 410 | - // If we got here then there was an error in this request. |
|
| 411 | - return array('status' => false, 'args' => $request_response); |
|
| 412 | - } |
|
| 413 | - $response_args = array(); |
|
| 414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
| 415 | - if ( ! isset($response_args['ACK'])) { |
|
| 416 | - return array('status' => false, 'args' => $request_response); |
|
| 417 | - } |
|
| 418 | - if ( |
|
| 419 | - ( |
|
| 420 | - isset($response_args['PAYERID']) |
|
| 421 | - || isset($response_args['TOKEN']) |
|
| 422 | - || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
| 423 | - || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
| 424 | - ) |
|
| 425 | - && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
| 426 | - ) { |
|
| 427 | - // Response status OK, return response parameters for further processing. |
|
| 428 | - return array('status' => true, 'args' => $response_args); |
|
| 429 | - } |
|
| 430 | - $errors = $this->_get_errors($response_args); |
|
| 431 | - return array('status' => false, 'args' => $errors); |
|
| 408 | + // If we got here then there was an error in this request. |
|
| 409 | + return array('status' => false, 'args' => $request_response); |
|
| 410 | + } |
|
| 411 | + $response_args = array(); |
|
| 412 | + parse_str( urldecode($request_response['body']), $response_args ); |
|
| 413 | + if ( ! isset($response_args['ACK'])) { |
|
| 414 | + return array('status' => false, 'args' => $request_response); |
|
| 415 | + } |
|
| 416 | + if ( |
|
| 417 | + ( |
|
| 418 | + isset($response_args['PAYERID']) |
|
| 419 | + || isset($response_args['TOKEN']) |
|
| 420 | + || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
| 421 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
| 422 | + ) |
|
| 423 | + && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
| 424 | + ) { |
|
| 425 | + // Response status OK, return response parameters for further processing. |
|
| 426 | + return array('status' => true, 'args' => $response_args); |
|
| 427 | + } |
|
| 428 | + $errors = $this->_get_errors($response_args); |
|
| 429 | + return array('status' => false, 'args' => $errors); |
|
| 432 | 430 | } |
| 433 | 431 | |
| 434 | 432 | |
| 435 | 433 | /** |
| 436 | - * Log a "Cleared" request. |
|
| 437 | - * |
|
| 438 | - * @param array $request |
|
| 434 | + * Log a "Cleared" request. |
|
| 435 | + * |
|
| 436 | + * @param array $request |
|
| 439 | 437 | * @param EEI_Payment $payment |
| 440 | 438 | * @param string $info |
| 441 | 439 | * @return void |
@@ -458,17 +456,17 @@ discard block |
||
| 458 | 456 | $n = 0; |
| 459 | 457 | while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
| 460 | 458 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
| 461 | - ? $data_array["L_ERRORCODE{$n}"] |
|
| 462 | - : ''; |
|
| 459 | + ? $data_array["L_ERRORCODE{$n}"] |
|
| 460 | + : ''; |
|
| 463 | 461 | $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
| 464 | - ? $data_array["L_SEVERITYCODE{$n}"] |
|
| 465 | - : ''; |
|
| 462 | + ? $data_array["L_SEVERITYCODE{$n}"] |
|
| 463 | + : ''; |
|
| 466 | 464 | $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
| 467 | - ? $data_array["L_SHORTMESSAGE{$n}"] |
|
| 468 | - : ''; |
|
| 465 | + ? $data_array["L_SHORTMESSAGE{$n}"] |
|
| 466 | + : ''; |
|
| 469 | 467 | $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
| 470 | - ? $data_array["L_LONGMESSAGE{$n}"] |
|
| 471 | - : ''; |
|
| 468 | + ? $data_array["L_LONGMESSAGE{$n}"] |
|
| 469 | + : ''; |
|
| 472 | 470 | |
| 473 | 471 | if ( $n === 0 ) { |
| 474 | 472 | $errors = array( |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * ---------------------------------------------- |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | *@param array $settings_array |
| 98 | 98 | */ |
| 99 | - public function set_settings( $settings_array ) { |
|
| 99 | + public function set_settings($settings_array) { |
|
| 100 | 100 | parent::set_settings($settings_array); |
| 101 | 101 | // Redirect URL. |
| 102 | 102 | $this->_base_gateway_url = $this->_debug_mode |
@@ -115,19 +115,19 @@ discard block |
||
| 115 | 115 | * @return \EE_Payment|\EEI_Payment |
| 116 | 116 | * @throws \EE_Error |
| 117 | 117 | */ |
| 118 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
| 119 | - if ( ! $payment instanceof EEI_Payment ) { |
|
| 120 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
| 121 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 118 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
| 119 | + if ( ! $payment instanceof EEI_Payment) { |
|
| 120 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
| 121 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 122 | 122 | return $payment; |
| 123 | 123 | } |
| 124 | 124 | $transaction = $payment->transaction(); |
| 125 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
| 126 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
| 127 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 125 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
| 126 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
| 127 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 128 | 128 | return $payment; |
| 129 | 129 | } |
| 130 | - $order_description = substr( $this->_format_order_description($payment), 0, 127 ); |
|
| 130 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
| 131 | 131 | $primary_registration = $transaction->primary_registration(); |
| 132 | 132 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
| 133 | 133 | $locale = explode('-', get_bloginfo('language')); |
@@ -141,37 +141,37 @@ discard block |
||
| 141 | 141 | 'RETURNURL' => $return_url, |
| 142 | 142 | 'CANCELURL' => $cancel_url, |
| 143 | 143 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
| 144 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
| 145 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
| 144 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
| 145 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
| 146 | 146 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
| 147 | 147 | ); |
| 148 | 148 | |
| 149 | 149 | // Show itemized list. |
| 150 | - if ( $this->_money->compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
| 150 | + if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
| 151 | 151 | $item_num = 0; |
| 152 | 152 | $itemized_sum = 0; |
| 153 | 153 | $total_line_items = $transaction->total_line_item(); |
| 154 | 154 | // Go through each item in the list. |
| 155 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
| 156 | - if ( $line_item instanceof EE_Line_Item ) { |
|
| 155 | + foreach ($total_line_items->get_items() as $line_item) { |
|
| 156 | + if ($line_item instanceof EE_Line_Item) { |
|
| 157 | 157 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
| 158 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
| 158 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
| 159 | 159 | continue; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $unit_price = $line_item->unit_price(); |
| 163 | 163 | $line_item_quantity = $line_item->quantity(); |
| 164 | 164 | // This is a discount. |
| 165 | - if ( $line_item->is_percent() ) { |
|
| 165 | + if ($line_item->is_percent()) { |
|
| 166 | 166 | $unit_price = $line_item->total(); |
| 167 | 167 | $line_item_quantity = 1; |
| 168 | 168 | } |
| 169 | 169 | // Item Name. |
| 170 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name( $line_item, $payment), 0, 127); |
|
| 170 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name($line_item, $payment), 0, 127); |
|
| 171 | 171 | // Item description. |
| 172 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc( $line_item, $payment), 0, 127); |
|
| 172 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc($line_item, $payment), 0, 127); |
|
| 173 | 173 | // Cost of individual item. |
| 174 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
| 174 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
| 175 | 175 | // Item Number. |
| 176 | 176 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
| 177 | 177 | // Item quantity. |
@@ -188,16 +188,16 @@ discard block |
||
| 188 | 188 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
| 189 | 189 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
| 190 | 190 | |
| 191 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
| 191 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
| 192 | 192 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
| 193 | 193 | // add the difference as an extra line item. |
| 194 | - if ( $this->_money->compare_floats( $itemized_sum_diff_from_txn_total, 0, '!=' ) ) { |
|
| 194 | + if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
| 195 | 195 | // Item Name. |
| 196 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
| 196 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
| 197 | 197 | // Item description. |
| 198 | 198 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = ''; |
| 199 | 199 | // Cost of individual item. |
| 200 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
| 200 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
| 201 | 201 | // Item Number. |
| 202 | 202 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
| 203 | 203 | // Item quantity. |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | } else { |
| 210 | 210 | // Just one Item. |
| 211 | 211 | // Item Name. |
| 212 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( $this->_format_partial_payment_line_item_name($payment), 0, 127 ); |
|
| 212 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr($this->_format_partial_payment_line_item_name($payment), 0, 127); |
|
| 213 | 213 | // Item description. |
| 214 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( $this->_format_partial_payment_line_item_desc($payment), 0, 127 ); |
|
| 214 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr($this->_format_partial_payment_line_item_desc($payment), 0, 127); |
|
| 215 | 215 | // Cost of individual item. |
| 216 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
| 216 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
| 217 | 217 | // Item Number. |
| 218 | 218 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
| 219 | 219 | // Item quantity. |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | // Digital item is sold. |
| 222 | 222 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
| 223 | 223 | // Item's sales S/H and tax amount. |
| 224 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
| 224 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
| 225 | 225 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
| 226 | 226 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
| 227 | 227 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
| 228 | 228 | } |
| 229 | 229 | // Automatically filling out shipping and contact information. |
| 230 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
| 231 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
| 230 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
| 231 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
| 232 | 232 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
| 233 | 233 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
| 234 | 234 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -237,14 +237,14 @@ discard block |
||
| 237 | 237 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
| 238 | 238 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
| 239 | 239 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
| 240 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
| 240 | + } elseif ( ! $this->_request_shipping_addr) { |
|
| 241 | 241 | // Do not request shipping details on the PP Checkout page. |
| 242 | 242 | $token_request_dtls['NOSHIPPING'] = '1'; |
| 243 | 243 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
| 244 | 244 | |
| 245 | 245 | } |
| 246 | 246 | // Used a business/personal logo on the PayPal page. |
| 247 | - if ( ! empty($this->_image_url) ) { |
|
| 247 | + if ( ! empty($this->_image_url)) { |
|
| 248 | 248 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
| 249 | 249 | } |
| 250 | 250 | $token_request_dtls = apply_filters( |
@@ -253,23 +253,23 @@ discard block |
||
| 253 | 253 | $this |
| 254 | 254 | ); |
| 255 | 255 | // Request PayPal token. |
| 256 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
| 257 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
| 258 | - $response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
| 259 | - if ( $token_rstatus['status'] ) { |
|
| 256 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
| 257 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
| 258 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
| 259 | + if ($token_rstatus['status']) { |
|
| 260 | 260 | // We got the Token so we may continue with the payment and redirect the client. |
| 261 | - $payment->set_details( $response_args ); |
|
| 261 | + $payment->set_details($response_args); |
|
| 262 | 262 | |
| 263 | 263 | $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
| 264 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
| 264 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
| 265 | 265 | } else { |
| 266 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
| 267 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
| 266 | + if (isset($response_args['L_ERRORCODE'])) { |
|
| 267 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
| 268 | 268 | } else { |
| 269 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
| 269 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
| 270 | 270 | } |
| 271 | - $payment->set_details( $response_args ); |
|
| 272 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 271 | + $payment->set_details($response_args); |
|
| 272 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | return $payment; |
@@ -285,22 +285,22 @@ discard block |
||
| 285 | 285 | * @param EEI_Transaction $transaction |
| 286 | 286 | * @return EEI_Payment |
| 287 | 287 | */ |
| 288 | - public function handle_payment_update( $update_info, $transaction ) { |
|
| 288 | + public function handle_payment_update($update_info, $transaction) { |
|
| 289 | 289 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
| 290 | 290 | |
| 291 | - if ( $payment instanceof EEI_Payment ) { |
|
| 292 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
| 291 | + if ($payment instanceof EEI_Payment) { |
|
| 292 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
| 293 | 293 | $transaction = $payment->transaction(); |
| 294 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
| 295 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
| 296 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 294 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
| 295 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
| 296 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 297 | 297 | return $payment; |
| 298 | 298 | } |
| 299 | 299 | $primary_registrant = $transaction->primary_registration(); |
| 300 | 300 | $payment_details = $payment->details(); |
| 301 | 301 | // Check if we still have the token. |
| 302 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
| 303 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 302 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
| 303 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 304 | 304 | return $payment; |
| 305 | 305 | } |
| 306 | 306 | |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | 'TOKEN' => $payment_details['TOKEN'] |
| 310 | 310 | ); |
| 311 | 311 | // Request Customer Details. |
| 312 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
| 313 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
| 314 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
| 315 | - if ( $cdetails_rstatus['status'] ) { |
|
| 312 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
| 313 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
| 314 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
| 315 | + if ($cdetails_rstatus['status']) { |
|
| 316 | 316 | // We got the PayerID so now we can Complete the transaction. |
| 317 | 317 | $docheckout_request_dtls = array( |
| 318 | 318 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -323,39 +323,39 @@ discard block |
||
| 323 | 323 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
| 324 | 324 | ); |
| 325 | 325 | // Payment Checkout/Capture. |
| 326 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
| 327 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
| 328 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
| 329 | - if ( $docheckout_rstatus['status'] ) { |
|
| 326 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
| 327 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
| 328 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
| 329 | + if ($docheckout_rstatus['status']) { |
|
| 330 | 330 | // All is well, payment approved. |
| 331 | 331 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
| 332 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
| 333 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0 ); |
|
| 334 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
| 335 | - $payment->set_details( $cdata_response_args ); |
|
| 336 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
| 337 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
| 332 | + $payment->set_extra_accntng($primary_registration_code); |
|
| 333 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0); |
|
| 334 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
| 335 | + $payment->set_details($cdata_response_args); |
|
| 336 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
| 337 | + $payment->set_status($this->_pay_model->approved_status()); |
|
| 338 | 338 | } else { |
| 339 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
| 340 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
| 339 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
| 340 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
| 341 | 341 | } else { |
| 342 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
| 342 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
| 343 | 343 | } |
| 344 | - $payment->set_details( $docheckout_response_args ); |
|
| 345 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
| 344 | + $payment->set_details($docheckout_response_args); |
|
| 345 | + $payment->set_status($this->_pay_model->declined_status()); |
|
| 346 | 346 | } |
| 347 | 347 | } else { |
| 348 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
| 349 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
| 348 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
| 349 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
| 350 | 350 | } else { |
| 351 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
| 351 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
| 352 | 352 | } |
| 353 | - $payment->set_details( $cdata_response_args ); |
|
| 354 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 353 | + $payment->set_details($cdata_response_args); |
|
| 354 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 355 | 355 | } |
| 356 | 356 | } else { |
| 357 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
| 358 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
| 357 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
| 358 | + $payment->set_status($this->_pay_model->failed_status()); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | return $payment; |
@@ -370,16 +370,16 @@ discard block |
||
| 370 | 370 | * @param EEI_Payment $payment |
| 371 | 371 | * @return mixed |
| 372 | 372 | */ |
| 373 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
| 373 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
| 374 | 374 | $request_dtls = array( |
| 375 | 375 | 'VERSION' => '204.0', |
| 376 | - 'USER' => urlencode( $this->_api_username ), |
|
| 377 | - 'PWD' => urlencode( $this->_api_password ), |
|
| 378 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
| 376 | + 'USER' => urlencode($this->_api_username), |
|
| 377 | + 'PWD' => urlencode($this->_api_password), |
|
| 378 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
| 379 | 379 | ); |
| 380 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
| 380 | + $dtls = array_merge($request_dtls, $request_params); |
|
| 381 | 381 | |
| 382 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
| 382 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
| 383 | 383 | // Request Customer Details. |
| 384 | 384 | $request_response = wp_remote_post( |
| 385 | 385 | $this->_base_gateway_url, |
@@ -389,11 +389,11 @@ discard block |
||
| 389 | 389 | 'httpversion' => '1.1', |
| 390 | 390 | 'cookies' => array(), |
| 391 | 391 | 'headers' => array(), |
| 392 | - 'body' => http_build_query( $dtls ) |
|
| 392 | + 'body' => http_build_query($dtls) |
|
| 393 | 393 | ) |
| 394 | 394 | ); |
| 395 | 395 | // Log the response. |
| 396 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
| 396 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
| 397 | 397 | |
| 398 | 398 | return $request_response; |
| 399 | 399 | } |
@@ -405,13 +405,13 @@ discard block |
||
| 405 | 405 | * @param mixed $request_response |
| 406 | 406 | * @return array |
| 407 | 407 | */ |
| 408 | - public function _ppExpress_check_response( $request_response ) { |
|
| 409 | - if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
|
| 408 | + public function _ppExpress_check_response($request_response) { |
|
| 409 | + if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
| 410 | 410 | // If we got here then there was an error in this request. |
| 411 | 411 | return array('status' => false, 'args' => $request_response); |
| 412 | 412 | } |
| 413 | 413 | $response_args = array(); |
| 414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
| 414 | + parse_str(urldecode($request_response['body']), $response_args); |
|
| 415 | 415 | if ( ! isset($response_args['ACK'])) { |
| 416 | 416 | return array('status' => false, 'args' => $request_response); |
| 417 | 417 | } |
@@ -440,10 +440,10 @@ discard block |
||
| 440 | 440 | * @param string $info |
| 441 | 441 | * @return void |
| 442 | 442 | */ |
| 443 | - private function _log_clean_request($request, $payment, $info ) { |
|
| 443 | + private function _log_clean_request($request, $payment, $info) { |
|
| 444 | 444 | $cleaned_request_data = $request; |
| 445 | 445 | unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
| 446 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
| 446 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | |
@@ -453,10 +453,10 @@ discard block |
||
| 453 | 453 | * @param array $data_array |
| 454 | 454 | * @return array |
| 455 | 455 | */ |
| 456 | - private function _get_errors( $data_array ) { |
|
| 456 | + private function _get_errors($data_array) { |
|
| 457 | 457 | $errors = array(); |
| 458 | 458 | $n = 0; |
| 459 | - while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
|
| 459 | + while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
| 460 | 460 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
| 461 | 461 | ? $data_array["L_ERRORCODE{$n}"] |
| 462 | 462 | : ''; |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | ? $data_array["L_LONGMESSAGE{$n}"] |
| 471 | 471 | : ''; |
| 472 | 472 | |
| 473 | - if ( $n === 0 ) { |
|
| 473 | + if ($n === 0) { |
|
| 474 | 474 | $errors = array( |
| 475 | 475 | 'L_ERRORCODE' => $l_error_code, |
| 476 | 476 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -478,10 +478,10 @@ discard block |
||
| 478 | 478 | 'L_SEVERITYCODE' => $l_severity_code |
| 479 | 479 | ); |
| 480 | 480 | } else { |
| 481 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
| 482 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
| 483 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
| 484 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
| 481 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
| 482 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
| 483 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
| 484 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | $n++; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -16,698 +16,698 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @return EED_Module|EED_Add_New_State |
|
| 21 | - */ |
|
| 22 | - public static function instance() |
|
| 23 | - { |
|
| 24 | - return parent::get_instance(__CLASS__); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 31 | - * |
|
| 32 | - * @return void |
|
| 33 | - */ |
|
| 34 | - public static function set_hooks() |
|
| 35 | - { |
|
| 36 | - add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
| 37 | - add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0); |
|
| 38 | - add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10); |
|
| 39 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
| 40 | - array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 41 | - add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
| 42 | - array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 43 | - add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
| 44 | - array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
| 45 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
| 46 | - array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
| 47 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
| 48 | - array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
| 49 | - add_filter('FHEE__EE_State_Select_Input____construct__state_options', |
|
| 50 | - array('EED_Add_New_State', 'state_options'), 10, 1); |
|
| 51 | - add_filter('FHEE__EE_Country_Select_Input____construct__country_options', |
|
| 52 | - array('EED_Add_New_State', 'country_options'), 10, 1); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 59 | - * |
|
| 60 | - * @return void |
|
| 61 | - */ |
|
| 62 | - public static function set_hooks_admin() |
|
| 63 | - { |
|
| 64 | - add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
| 65 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
| 66 | - array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 67 | - add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
| 68 | - array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 69 | - add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
| 70 | - add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
| 71 | - add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
| 72 | - array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
| 73 | - add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
| 74 | - array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
| 75 | - add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
| 76 | - array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
| 77 | - add_filter('FHEE__EE_State_Select_Input____construct__state_options', |
|
| 78 | - array('EED_Add_New_State', 'state_options'), 10, 1); |
|
| 79 | - add_filter('FHEE__EE_Country_Select_Input____construct__country_options', |
|
| 80 | - array('EED_Add_New_State', 'country_options'), 10, 1); |
|
| 81 | - add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', |
|
| 82 | - array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1); |
|
| 83 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
| 84 | - array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
| 85 | - add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
| 86 | - array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @return void |
|
| 93 | - */ |
|
| 94 | - public static function set_definitions() |
|
| 95 | - { |
|
| 96 | - define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 97 | - define('ANS_TEMPLATES_PATH', str_replace( |
|
| 98 | - '\\', |
|
| 99 | - DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
| 100 | - ); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @param WP $WP |
|
| 107 | - * @return void |
|
| 108 | - */ |
|
| 109 | - public function run($WP) |
|
| 110 | - { |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @return void |
|
| 117 | - */ |
|
| 118 | - public static function translate_js_strings() |
|
| 119 | - { |
|
| 120 | - EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__( |
|
| 121 | - 'In order to proceed, you need to select the Country that your State/Province belongs to.', |
|
| 122 | - 'event_espresso' |
|
| 123 | - ); |
|
| 124 | - EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__( |
|
| 125 | - 'In order to proceed, you need to enter the name of your State/Province.', |
|
| 126 | - 'event_espresso' |
|
| 127 | - ); |
|
| 128 | - EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__( |
|
| 129 | - 'In order to proceed, you need to enter an abbreviation for the name of your State/Province.', |
|
| 130 | - 'event_espresso' |
|
| 131 | - ); |
|
| 132 | - EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__( |
|
| 133 | - 'The new state was successfully saved to the database.', |
|
| 134 | - 'event_espresso' |
|
| 135 | - ); |
|
| 136 | - EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__( |
|
| 137 | - 'An unknown error has occurred on the server while saving the new state to the database.', |
|
| 138 | - 'event_espresso' |
|
| 139 | - ); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @return void |
|
| 146 | - */ |
|
| 147 | - public static function wp_enqueue_scripts() |
|
| 148 | - { |
|
| 149 | - if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
|
| 150 | - wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js', |
|
| 151 | - array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
|
| 152 | - wp_enqueue_script('add_new_state'); |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * display_add_new_state_micro_form |
|
| 160 | - * |
|
| 161 | - * @param EE_Form_Section_Proper $question_group_reg_form |
|
| 162 | - * @return string |
|
| 163 | - * @throws EE_Error |
|
| 164 | - */ |
|
| 165 | - // public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){ |
|
| 166 | - public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form) |
|
| 167 | - { |
|
| 168 | - // only add the 'new_state_micro_form' when displaying reg forms, |
|
| 169 | - // not during processing since we process the 'new_state_micro_form' in it's own AJAX request |
|
| 170 | - $action = EE_Registry::instance()->REQ->get('action', ''); |
|
| 171 | - // is the "state" question in this form section? |
|
| 172 | - $input = $question_group_reg_form->get_subsection('state'); |
|
| 173 | - if ($action === 'process_reg_step' || $action === 'update_reg_step') { |
|
| 174 | - //ok then all we need to do is make sure the input's HTML name is consistent |
|
| 175 | - //by forcing it to set it now, like it did while getting the form for display |
|
| 176 | - if ($input instanceof EE_State_Select_Input) { |
|
| 177 | - $input->html_name(); |
|
| 178 | - } |
|
| 179 | - return $question_group_reg_form; |
|
| 180 | - } |
|
| 181 | - // we're only doing this for state select inputs |
|
| 182 | - if ($input instanceof EE_State_Select_Input) { |
|
| 183 | - // grab any set values from the request |
|
| 184 | - $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name()); |
|
| 185 | - $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name()); |
|
| 186 | - $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name()); |
|
| 187 | - $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
|
| 188 | - $country_options = array(); |
|
| 189 | - $countries = EEM_Country::instance()->get_all_countries(); |
|
| 190 | - if (! empty($countries)) { |
|
| 191 | - foreach ($countries as $country) { |
|
| 192 | - if ($country instanceof EE_Country) { |
|
| 193 | - $country_options[$country->ID()] = $country->name(); |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - $new_state_micro_form = new EE_Form_Section_Proper( |
|
| 198 | - array( |
|
| 199 | - 'name' => 'new_state_micro_form', |
|
| 200 | - 'html_id' => 'new_state_micro_form', |
|
| 201 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 202 | - 'subsections' => array( |
|
| 203 | - // add hidden input to indicate that a new state is being added |
|
| 204 | - 'add_new_state' => new EE_Hidden_Input( |
|
| 205 | - array( |
|
| 206 | - 'html_name' => str_replace( |
|
| 207 | - 'state', |
|
| 208 | - 'nsmf_add_new_state', $input->html_name() |
|
| 209 | - ), |
|
| 210 | - 'html_id' => str_replace( |
|
| 211 | - 'state', |
|
| 212 | - 'nsmf_add_new_state', $input->html_id() |
|
| 213 | - ), |
|
| 214 | - 'default' => 0, |
|
| 215 | - ) |
|
| 216 | - ), |
|
| 217 | - // add link for displaying hidden container |
|
| 218 | - 'click_here_link' => new EE_Form_Section_HTML( |
|
| 219 | - apply_filters( |
|
| 220 | - 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link', |
|
| 221 | - EEH_HTML::link( |
|
| 222 | - '', |
|
| 223 | - esc_html__('click here to add a new state/province', 'event_espresso'), |
|
| 224 | - '', |
|
| 225 | - 'display-' . $input->html_id(), |
|
| 226 | - 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
|
| 227 | - '', |
|
| 228 | - 'data-target="' . $input->html_id() . '"' |
|
| 229 | - ) |
|
| 230 | - ) |
|
| 231 | - ), |
|
| 232 | - // add initial html for hidden container |
|
| 233 | - 'add_new_state_micro_form' => new EE_Form_Section_HTML( |
|
| 234 | - apply_filters( |
|
| 235 | - 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
|
| 236 | - EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', |
|
| 237 | - 'display: none;') . |
|
| 238 | - EEH_HTML::h6( |
|
| 239 | - esc_html__( |
|
| 240 | - 'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:', |
|
| 241 | - 'event_espresso' |
|
| 242 | - ) |
|
| 243 | - ) . |
|
| 244 | - EEH_HTML::ul() . |
|
| 245 | - EEH_HTML::li( |
|
| 246 | - esc_html__( |
|
| 247 | - 'first select the Country that your State/Province belongs to', |
|
| 248 | - 'event_espresso' |
|
| 249 | - ) |
|
| 250 | - ) . |
|
| 251 | - EEH_HTML::li( |
|
| 252 | - esc_html__('enter the name of your State/Province', 'event_espresso') |
|
| 253 | - ) . |
|
| 254 | - EEH_HTML::li( |
|
| 255 | - esc_html__( |
|
| 256 | - 'enter a two to six letter abbreviation for the name of your State/Province', |
|
| 257 | - 'event_espresso' |
|
| 258 | - ) |
|
| 259 | - ) . |
|
| 260 | - EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) . |
|
| 261 | - EEH_HTML::ulx() |
|
| 262 | - ) |
|
| 263 | - ), |
|
| 264 | - // NEW STATE COUNTRY |
|
| 265 | - 'new_state_country' => new EE_Country_Select_Input( |
|
| 266 | - $country_options, |
|
| 267 | - array( |
|
| 268 | - 'html_name' => $country_name, |
|
| 269 | - 'html_id' => str_replace( |
|
| 270 | - 'state', |
|
| 271 | - 'nsmf_new_state_country', $input->html_id() |
|
| 272 | - ), |
|
| 273 | - 'html_class' => $input->html_class() . ' new-state-country', |
|
| 274 | - 'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'), |
|
| 275 | - 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
|
| 276 | - 'required' => false, |
|
| 277 | - ) |
|
| 278 | - ), |
|
| 279 | - // NEW STATE NAME |
|
| 280 | - 'new_state_name' => new EE_Text_Input( |
|
| 281 | - array( |
|
| 282 | - 'html_name' => $state_name, |
|
| 283 | - 'html_id' => str_replace( |
|
| 284 | - 'state', |
|
| 285 | - 'nsmf_new_state_name', $input->html_id() |
|
| 286 | - ), |
|
| 287 | - 'html_class' => $input->html_class() . ' new-state-state', |
|
| 288 | - 'html_label_text' => esc_html__('New State/Province Name', |
|
| 289 | - 'event_espresso'), |
|
| 290 | - 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
|
| 291 | - 'required' => false, |
|
| 292 | - ) |
|
| 293 | - ), |
|
| 294 | - 'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()), |
|
| 295 | - // NEW STATE NAME |
|
| 296 | - 'new_state_abbrv' => new EE_Text_Input( |
|
| 297 | - array( |
|
| 298 | - 'html_name' => $abbrv_name, |
|
| 299 | - 'html_id' => str_replace('state', 'nsmf_new_state_abbrv', |
|
| 300 | - $input->html_id()), |
|
| 301 | - 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
| 302 | - 'html_label_text' => esc_html__( |
|
| 303 | - 'New State/Province Abbreviation', |
|
| 304 | - 'event_espresso' |
|
| 305 | - ) . ' *', |
|
| 306 | - 'html_other_attributes' => 'size="24"', |
|
| 307 | - 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), |
|
| 308 | - 'required' => false, |
|
| 309 | - ) |
|
| 310 | - ), |
|
| 311 | - // "submit" button |
|
| 312 | - 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
|
| 313 | - apply_filters( |
|
| 314 | - 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
|
| 315 | - EEH_HTML::nbsp(3) . |
|
| 316 | - EEH_HTML::link( |
|
| 317 | - '', |
|
| 318 | - esc_html__('ADD', 'event_espresso'), |
|
| 319 | - '', |
|
| 320 | - 'submit-' . $new_state_submit_id, |
|
| 321 | - 'ee-form-add-new-state-submit button button-secondary', |
|
| 322 | - '', |
|
| 323 | - 'data-target="' . $new_state_submit_id . '"' |
|
| 324 | - ) |
|
| 325 | - ) |
|
| 326 | - ), |
|
| 327 | - // extra info |
|
| 328 | - 'add_new_state_extra' => new EE_Form_Section_HTML( |
|
| 329 | - apply_filters( |
|
| 330 | - 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra', |
|
| 331 | - EEH_HTML::br(2) |
|
| 332 | - . |
|
| 333 | - EEH_HTML::div('', '', 'small-text') |
|
| 334 | - . |
|
| 335 | - EEH_HTML::strong( |
|
| 336 | - '* ' . |
|
| 337 | - esc_html__( |
|
| 338 | - 'Don\'t know your State/Province Abbreviation?', |
|
| 339 | - 'event_espresso' |
|
| 340 | - ) |
|
| 341 | - ) |
|
| 342 | - . |
|
| 343 | - EEH_HTML::br() |
|
| 344 | - . |
|
| 345 | - sprintf( |
|
| 346 | - esc_html__( |
|
| 347 | - 'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', |
|
| 348 | - 'event_espresso' |
|
| 349 | - ), |
|
| 350 | - EEH_HTML::link( |
|
| 351 | - 'http://en.wikipedia.org/wiki/ISO_3166-2', |
|
| 352 | - 'http://en.wikipedia.org/wiki/ISO_3166-2', |
|
| 353 | - '', |
|
| 354 | - '', |
|
| 355 | - 'ee-form-add-new-state-wiki-lnk', |
|
| 356 | - '', |
|
| 357 | - 'target="_blank"' |
|
| 358 | - ) |
|
| 359 | - ) |
|
| 360 | - . |
|
| 361 | - EEH_HTML::divx() |
|
| 362 | - . |
|
| 363 | - EEH_HTML::br() |
|
| 364 | - . |
|
| 365 | - EEH_HTML::link( |
|
| 366 | - '', |
|
| 367 | - esc_html__('cancel new State/Province', 'event_espresso'), |
|
| 368 | - '', |
|
| 369 | - 'hide-' . $input->html_id(), |
|
| 370 | - 'ee-form-cancel-new-state-lnk smaller-text', |
|
| 371 | - '', |
|
| 372 | - 'data-target="' . $input->html_id() . '"' |
|
| 373 | - ) |
|
| 374 | - . |
|
| 375 | - EEH_HTML::divx() |
|
| 376 | - . |
|
| 377 | - EEH_HTML::br() |
|
| 378 | - ) |
|
| 379 | - ), |
|
| 380 | - ), |
|
| 381 | - ) |
|
| 382 | - ); |
|
| 383 | - $question_group_reg_form->add_subsections( |
|
| 384 | - array('new_state_micro_form' => $new_state_micro_form), |
|
| 385 | - 'state', |
|
| 386 | - false |
|
| 387 | - ); |
|
| 388 | - } |
|
| 389 | - return $question_group_reg_form; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * set_new_state_input_width |
|
| 396 | - * |
|
| 397 | - * @return int|string |
|
| 398 | - * @throws EE_Error |
|
| 399 | - */ |
|
| 400 | - public static function add_new_state() |
|
| 401 | - { |
|
| 402 | - $REQ = EE_Registry::instance()->load_core('Request_Handler'); |
|
| 403 | - if (absint($REQ->get('nsmf_add_new_state')) === 1) { |
|
| 404 | - EE_Registry::instance()->load_model('State'); |
|
| 405 | - // grab country ISO code, new state name, and new state abbreviation |
|
| 406 | - $state_country = $REQ->is_set('nsmf_new_state_country') |
|
| 407 | - ? sanitize_text_field($REQ->get('nsmf_new_state_country')) |
|
| 408 | - : false; |
|
| 409 | - $state_name = $REQ->is_set('nsmf_new_state_name') |
|
| 410 | - ? sanitize_text_field($REQ->get('nsmf_new_state_name')) |
|
| 411 | - : false; |
|
| 412 | - $state_abbr = $REQ->is_set('nsmf_new_state_abbrv') |
|
| 413 | - ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv')) |
|
| 414 | - : false; |
|
| 415 | - if ($state_country && $state_name && $state_abbr) { |
|
| 416 | - $new_state = EED_Add_New_State::save_new_state_to_db(array( |
|
| 417 | - 'CNT_ISO' => strtoupper($state_country), |
|
| 418 | - 'STA_abbrev' => strtoupper($state_abbr), |
|
| 419 | - 'STA_name' => ucwords($state_name), |
|
| 420 | - 'STA_active' => false, |
|
| 421 | - )); |
|
| 422 | - if ($new_state instanceof EE_State) { |
|
| 423 | - // clean house |
|
| 424 | - EE_Registry::instance()->REQ->un_set('nsmf_add_new_state'); |
|
| 425 | - EE_Registry::instance()->REQ->un_set('nsmf_new_state_country'); |
|
| 426 | - EE_Registry::instance()->REQ->un_set('nsmf_new_state_name'); |
|
| 427 | - EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv'); |
|
| 428 | - // get any existing new states |
|
| 429 | - $new_states = EE_Registry::instance()->SSN->get_session_data( |
|
| 430 | - 'nsmf_new_states' |
|
| 431 | - ); |
|
| 432 | - $new_states[$new_state->ID()] = $new_state; |
|
| 433 | - EE_Registry::instance()->SSN->set_session_data( |
|
| 434 | - array('nsmf_new_states' => $new_states) |
|
| 435 | - ); |
|
| 436 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 437 | - echo wp_json_encode(array( |
|
| 438 | - 'success' => true, |
|
| 439 | - 'id' => $new_state->ID(), |
|
| 440 | - 'name' => $new_state->name(), |
|
| 441 | - 'abbrev' => $new_state->abbrev(), |
|
| 442 | - 'country_iso' => $new_state->country_iso(), |
|
| 443 | - 'country_name' => $new_state->country()->name(), |
|
| 444 | - )); |
|
| 445 | - exit(); |
|
| 446 | - } |
|
| 447 | - return $new_state->ID(); |
|
| 448 | - } |
|
| 449 | - } else { |
|
| 450 | - $error = esc_html__( |
|
| 451 | - 'A new State/Province could not be added because invalid or missing data was received.', |
|
| 452 | - 'event_espresso' |
|
| 453 | - ); |
|
| 454 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 455 | - echo wp_json_encode(array('error' => $error)); |
|
| 456 | - exit(); |
|
| 457 | - } |
|
| 458 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 459 | - } |
|
| 460 | - } |
|
| 461 | - return false; |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - |
|
| 465 | - |
|
| 466 | - /** |
|
| 467 | - * recursively drills down through request params to remove any that were added by this module |
|
| 468 | - * |
|
| 469 | - * @param array $request_params |
|
| 470 | - * @return array |
|
| 471 | - */ |
|
| 472 | - public static function filter_checkout_request_params($request_params) |
|
| 473 | - { |
|
| 474 | - foreach ($request_params as $form_section) { |
|
| 475 | - if (is_array($form_section)) { |
|
| 476 | - EED_Add_New_State::unset_new_state_request_params($form_section); |
|
| 477 | - EED_Add_New_State::filter_checkout_request_params($form_section); |
|
| 478 | - } |
|
| 479 | - } |
|
| 480 | - return $request_params; |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * @param array $request_params |
|
| 487 | - * @return array |
|
| 488 | - */ |
|
| 489 | - public static function unset_new_state_request_params($request_params) |
|
| 490 | - { |
|
| 491 | - unset( |
|
| 492 | - $request_params['new_state_micro_form'], |
|
| 493 | - $request_params['new_state_micro_add_new_state'], |
|
| 494 | - $request_params['new_state_micro_new_state_country'], |
|
| 495 | - $request_params['new_state_micro_new_state_name'], |
|
| 496 | - $request_params['new_state_micro_new_state_abbrv'] |
|
| 497 | - ); |
|
| 498 | - return $request_params; |
|
| 499 | - } |
|
| 500 | - |
|
| 501 | - |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * @param array $props_n_values |
|
| 505 | - * @return bool |
|
| 506 | - * @throws EE_Error |
|
| 507 | - */ |
|
| 508 | - public static function save_new_state_to_db($props_n_values = array()) |
|
| 509 | - { |
|
| 510 | - $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
|
| 511 | - if (! empty($existing_state)) { |
|
| 512 | - return array_pop($existing_state); |
|
| 513 | - } |
|
| 514 | - $new_state = EE_State::new_instance($props_n_values); |
|
| 515 | - if ($new_state instanceof EE_State) { |
|
| 516 | - // if not non-ajax admin |
|
| 517 | - $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
| 518 | - $new_state_notice = sprintf( |
|
| 519 | - esc_html__( |
|
| 520 | - 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', |
|
| 521 | - 'event_espresso' |
|
| 522 | - ), |
|
| 523 | - '<b>' . $new_state->name() . '</b>', |
|
| 524 | - '<b>' . $new_state->abbrev() . '</b>', |
|
| 525 | - '<b>' . $new_state->country()->name() . '</b>', |
|
| 526 | - '<a href="' . add_query_arg(array( |
|
| 527 | - 'page' => 'espresso_general_settings', |
|
| 528 | - 'action' => 'country_settings', |
|
| 529 | - 'country' => $new_state->country_iso(), |
|
| 530 | - ), admin_url('admin.php')) . '">' . esc_html__('Event Espresso - General Settings > Countries Tab', |
|
| 531 | - 'event_espresso') . '</a>', |
|
| 532 | - '<br />' |
|
| 533 | - ); |
|
| 534 | - EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
|
| 535 | - $new_state->save(); |
|
| 536 | - EEM_State::instance()->reset_cached_states(); |
|
| 537 | - return $new_state; |
|
| 538 | - } |
|
| 539 | - return false; |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - |
|
| 543 | - |
|
| 544 | - /** |
|
| 545 | - * @param string $CNT_ISO |
|
| 546 | - * @param string $STA_ID |
|
| 547 | - * @param array $cols_n_values |
|
| 548 | - * @return void |
|
| 549 | - */ |
|
| 550 | - public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) |
|
| 551 | - { |
|
| 552 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false; |
|
| 553 | - if (! $CNT_ISO) { |
|
| 554 | - EE_Error::add_error( |
|
| 555 | - esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'), |
|
| 556 | - __FILE__, |
|
| 557 | - __FUNCTION__, |
|
| 558 | - __LINE__ |
|
| 559 | - ); |
|
| 560 | - } |
|
| 561 | - $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] |
|
| 562 | - : false; |
|
| 563 | - if (! $STA_abbrev && ! empty($STA_ID)) { |
|
| 564 | - $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
| 565 | - if ($state instanceof EE_State) { |
|
| 566 | - $STA_abbrev = $state->abbrev(); |
|
| 567 | - } |
|
| 568 | - } |
|
| 569 | - if (! $STA_abbrev) { |
|
| 570 | - EE_Error::add_error( |
|
| 571 | - esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'), |
|
| 572 | - __FILE__, |
|
| 573 | - __FUNCTION__, |
|
| 574 | - __LINE__ |
|
| 575 | - ); |
|
| 576 | - } |
|
| 577 | - EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true); |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - |
|
| 581 | - |
|
| 582 | - /** |
|
| 583 | - * @param EE_State[] $state_options |
|
| 584 | - * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
| 585 | - * @param EE_Registration $registration |
|
| 586 | - * @param EE_Question $question |
|
| 587 | - * @param $answer |
|
| 588 | - * @return array |
|
| 589 | - */ |
|
| 590 | - public static function inject_new_reg_state_into_options( |
|
| 591 | - $state_options = array(), |
|
| 592 | - EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
| 593 | - EE_Registration $registration, |
|
| 594 | - EE_Question $question, |
|
| 595 | - $answer |
|
| 596 | - ) { |
|
| 597 | - if ($answer instanceof EE_Answer && $question instanceof EE_Question |
|
| 598 | - && $question->type() |
|
| 599 | - === EEM_Question::QST_type_state |
|
| 600 | - ) { |
|
| 601 | - $STA_ID = $answer->value(); |
|
| 602 | - if (! empty($STA_ID)) { |
|
| 603 | - $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
| 604 | - if ($state instanceof EE_State) { |
|
| 605 | - $country = $state->country(); |
|
| 606 | - if ($country instanceof EE_Country) { |
|
| 607 | - if (! isset($state_options[$country->name()])) { |
|
| 608 | - $state_options[$country->name()] = array(); |
|
| 609 | - } |
|
| 610 | - if (! isset($state_options[$country->name()][$STA_ID])) { |
|
| 611 | - $state_options[$country->name()][$STA_ID] = $state->name(); |
|
| 612 | - } |
|
| 613 | - } |
|
| 614 | - } |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - return $state_options; |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * @param EE_Country[] $country_options |
|
| 624 | - * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
| 625 | - * @param EE_Registration $registration |
|
| 626 | - * @param EE_Question $question |
|
| 627 | - * @param $answer |
|
| 628 | - * @return array |
|
| 629 | - */ |
|
| 630 | - public static function inject_new_reg_country_into_options( |
|
| 631 | - $country_options = array(), |
|
| 632 | - EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
| 633 | - EE_Registration $registration, |
|
| 634 | - EE_Question $question, |
|
| 635 | - $answer |
|
| 636 | - ) { |
|
| 637 | - if ($answer instanceof EE_Answer && $question instanceof EE_Question |
|
| 638 | - && $question->type() |
|
| 639 | - === EEM_Question::QST_type_country |
|
| 640 | - ) { |
|
| 641 | - $CNT_ISO = $answer->value(); |
|
| 642 | - if (! empty($CNT_ISO)) { |
|
| 643 | - $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
| 644 | - if ($country instanceof EE_Country) { |
|
| 645 | - if (! isset($country_options[$CNT_ISO])) { |
|
| 646 | - $country_options[$CNT_ISO] = $country->name(); |
|
| 647 | - } |
|
| 648 | - } |
|
| 649 | - } |
|
| 650 | - } |
|
| 651 | - return $country_options; |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - |
|
| 655 | - |
|
| 656 | - /** |
|
| 657 | - * @param EE_State[] $state_options |
|
| 658 | - * @return array |
|
| 659 | - * @throws EE_Error |
|
| 660 | - */ |
|
| 661 | - public static function state_options($state_options = array()) |
|
| 662 | - { |
|
| 663 | - $new_states = EED_Add_New_State::_get_new_states(); |
|
| 664 | - foreach ($new_states as $new_state) { |
|
| 665 | - if ( |
|
| 666 | - $new_state instanceof EE_State |
|
| 667 | - && $new_state->country() instanceof EE_Country |
|
| 668 | - ) { |
|
| 669 | - $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name(); |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - return $state_options; |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - |
|
| 676 | - |
|
| 677 | - /** |
|
| 678 | - * @return array |
|
| 679 | - */ |
|
| 680 | - protected static function _get_new_states() |
|
| 681 | - { |
|
| 682 | - $new_states = array(); |
|
| 683 | - if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 684 | - $new_states = EE_Registry::instance()->SSN->get_session_data( |
|
| 685 | - 'nsmf_new_states' |
|
| 686 | - ); |
|
| 687 | - } |
|
| 688 | - return is_array($new_states) ? $new_states : array(); |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - |
|
| 692 | - |
|
| 693 | - /** |
|
| 694 | - * @param EE_Country[] $country_options |
|
| 695 | - * @return array |
|
| 696 | - * @throws EE_Error |
|
| 697 | - */ |
|
| 698 | - public static function country_options($country_options = array()) |
|
| 699 | - { |
|
| 700 | - $new_states = EED_Add_New_State::_get_new_states(); |
|
| 701 | - foreach ($new_states as $new_state) { |
|
| 702 | - if ( |
|
| 703 | - $new_state instanceof EE_State |
|
| 704 | - && $new_state->country() instanceof EE_Country |
|
| 705 | - ) { |
|
| 706 | - $country_options[$new_state->country()->ID()] = $new_state->country()->name(); |
|
| 707 | - } |
|
| 708 | - } |
|
| 709 | - return $country_options; |
|
| 710 | - } |
|
| 19 | + /** |
|
| 20 | + * @return EED_Module|EED_Add_New_State |
|
| 21 | + */ |
|
| 22 | + public static function instance() |
|
| 23 | + { |
|
| 24 | + return parent::get_instance(__CLASS__); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 31 | + * |
|
| 32 | + * @return void |
|
| 33 | + */ |
|
| 34 | + public static function set_hooks() |
|
| 35 | + { |
|
| 36 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
| 37 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0); |
|
| 38 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10); |
|
| 39 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
| 40 | + array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 41 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
| 42 | + array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 43 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
| 44 | + array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
| 45 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
| 46 | + array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
| 47 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
| 48 | + array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
| 49 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', |
|
| 50 | + array('EED_Add_New_State', 'state_options'), 10, 1); |
|
| 51 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', |
|
| 52 | + array('EED_Add_New_State', 'country_options'), 10, 1); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 59 | + * |
|
| 60 | + * @return void |
|
| 61 | + */ |
|
| 62 | + public static function set_hooks_admin() |
|
| 63 | + { |
|
| 64 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
| 65 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
| 66 | + array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 67 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
| 68 | + array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
| 69 | + add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
| 70 | + add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
| 71 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
| 72 | + array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
| 73 | + add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
| 74 | + array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
| 75 | + add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
| 76 | + array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
| 77 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', |
|
| 78 | + array('EED_Add_New_State', 'state_options'), 10, 1); |
|
| 79 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', |
|
| 80 | + array('EED_Add_New_State', 'country_options'), 10, 1); |
|
| 81 | + add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', |
|
| 82 | + array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1); |
|
| 83 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
| 84 | + array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
| 85 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
| 86 | + array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @return void |
|
| 93 | + */ |
|
| 94 | + public static function set_definitions() |
|
| 95 | + { |
|
| 96 | + define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 97 | + define('ANS_TEMPLATES_PATH', str_replace( |
|
| 98 | + '\\', |
|
| 99 | + DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
| 100 | + ); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @param WP $WP |
|
| 107 | + * @return void |
|
| 108 | + */ |
|
| 109 | + public function run($WP) |
|
| 110 | + { |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @return void |
|
| 117 | + */ |
|
| 118 | + public static function translate_js_strings() |
|
| 119 | + { |
|
| 120 | + EE_Registry::$i18n_js_strings['ans_no_country'] = esc_html__( |
|
| 121 | + 'In order to proceed, you need to select the Country that your State/Province belongs to.', |
|
| 122 | + 'event_espresso' |
|
| 123 | + ); |
|
| 124 | + EE_Registry::$i18n_js_strings['ans_no_name'] = esc_html__( |
|
| 125 | + 'In order to proceed, you need to enter the name of your State/Province.', |
|
| 126 | + 'event_espresso' |
|
| 127 | + ); |
|
| 128 | + EE_Registry::$i18n_js_strings['ans_no_abbreviation'] = esc_html__( |
|
| 129 | + 'In order to proceed, you need to enter an abbreviation for the name of your State/Province.', |
|
| 130 | + 'event_espresso' |
|
| 131 | + ); |
|
| 132 | + EE_Registry::$i18n_js_strings['ans_save_success'] = esc_html__( |
|
| 133 | + 'The new state was successfully saved to the database.', |
|
| 134 | + 'event_espresso' |
|
| 135 | + ); |
|
| 136 | + EE_Registry::$i18n_js_strings['ans_server_save_error'] = esc_html__( |
|
| 137 | + 'An unknown error has occurred on the server while saving the new state to the database.', |
|
| 138 | + 'event_espresso' |
|
| 139 | + ); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @return void |
|
| 146 | + */ |
|
| 147 | + public static function wp_enqueue_scripts() |
|
| 148 | + { |
|
| 149 | + if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
|
| 150 | + wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js', |
|
| 151 | + array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
|
| 152 | + wp_enqueue_script('add_new_state'); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * display_add_new_state_micro_form |
|
| 160 | + * |
|
| 161 | + * @param EE_Form_Section_Proper $question_group_reg_form |
|
| 162 | + * @return string |
|
| 163 | + * @throws EE_Error |
|
| 164 | + */ |
|
| 165 | + // public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){ |
|
| 166 | + public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form) |
|
| 167 | + { |
|
| 168 | + // only add the 'new_state_micro_form' when displaying reg forms, |
|
| 169 | + // not during processing since we process the 'new_state_micro_form' in it's own AJAX request |
|
| 170 | + $action = EE_Registry::instance()->REQ->get('action', ''); |
|
| 171 | + // is the "state" question in this form section? |
|
| 172 | + $input = $question_group_reg_form->get_subsection('state'); |
|
| 173 | + if ($action === 'process_reg_step' || $action === 'update_reg_step') { |
|
| 174 | + //ok then all we need to do is make sure the input's HTML name is consistent |
|
| 175 | + //by forcing it to set it now, like it did while getting the form for display |
|
| 176 | + if ($input instanceof EE_State_Select_Input) { |
|
| 177 | + $input->html_name(); |
|
| 178 | + } |
|
| 179 | + return $question_group_reg_form; |
|
| 180 | + } |
|
| 181 | + // we're only doing this for state select inputs |
|
| 182 | + if ($input instanceof EE_State_Select_Input) { |
|
| 183 | + // grab any set values from the request |
|
| 184 | + $country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name()); |
|
| 185 | + $state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name()); |
|
| 186 | + $abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name()); |
|
| 187 | + $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
|
| 188 | + $country_options = array(); |
|
| 189 | + $countries = EEM_Country::instance()->get_all_countries(); |
|
| 190 | + if (! empty($countries)) { |
|
| 191 | + foreach ($countries as $country) { |
|
| 192 | + if ($country instanceof EE_Country) { |
|
| 193 | + $country_options[$country->ID()] = $country->name(); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + $new_state_micro_form = new EE_Form_Section_Proper( |
|
| 198 | + array( |
|
| 199 | + 'name' => 'new_state_micro_form', |
|
| 200 | + 'html_id' => 'new_state_micro_form', |
|
| 201 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 202 | + 'subsections' => array( |
|
| 203 | + // add hidden input to indicate that a new state is being added |
|
| 204 | + 'add_new_state' => new EE_Hidden_Input( |
|
| 205 | + array( |
|
| 206 | + 'html_name' => str_replace( |
|
| 207 | + 'state', |
|
| 208 | + 'nsmf_add_new_state', $input->html_name() |
|
| 209 | + ), |
|
| 210 | + 'html_id' => str_replace( |
|
| 211 | + 'state', |
|
| 212 | + 'nsmf_add_new_state', $input->html_id() |
|
| 213 | + ), |
|
| 214 | + 'default' => 0, |
|
| 215 | + ) |
|
| 216 | + ), |
|
| 217 | + // add link for displaying hidden container |
|
| 218 | + 'click_here_link' => new EE_Form_Section_HTML( |
|
| 219 | + apply_filters( |
|
| 220 | + 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link', |
|
| 221 | + EEH_HTML::link( |
|
| 222 | + '', |
|
| 223 | + esc_html__('click here to add a new state/province', 'event_espresso'), |
|
| 224 | + '', |
|
| 225 | + 'display-' . $input->html_id(), |
|
| 226 | + 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
|
| 227 | + '', |
|
| 228 | + 'data-target="' . $input->html_id() . '"' |
|
| 229 | + ) |
|
| 230 | + ) |
|
| 231 | + ), |
|
| 232 | + // add initial html for hidden container |
|
| 233 | + 'add_new_state_micro_form' => new EE_Form_Section_HTML( |
|
| 234 | + apply_filters( |
|
| 235 | + 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
|
| 236 | + EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', |
|
| 237 | + 'display: none;') . |
|
| 238 | + EEH_HTML::h6( |
|
| 239 | + esc_html__( |
|
| 240 | + 'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:', |
|
| 241 | + 'event_espresso' |
|
| 242 | + ) |
|
| 243 | + ) . |
|
| 244 | + EEH_HTML::ul() . |
|
| 245 | + EEH_HTML::li( |
|
| 246 | + esc_html__( |
|
| 247 | + 'first select the Country that your State/Province belongs to', |
|
| 248 | + 'event_espresso' |
|
| 249 | + ) |
|
| 250 | + ) . |
|
| 251 | + EEH_HTML::li( |
|
| 252 | + esc_html__('enter the name of your State/Province', 'event_espresso') |
|
| 253 | + ) . |
|
| 254 | + EEH_HTML::li( |
|
| 255 | + esc_html__( |
|
| 256 | + 'enter a two to six letter abbreviation for the name of your State/Province', |
|
| 257 | + 'event_espresso' |
|
| 258 | + ) |
|
| 259 | + ) . |
|
| 260 | + EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) . |
|
| 261 | + EEH_HTML::ulx() |
|
| 262 | + ) |
|
| 263 | + ), |
|
| 264 | + // NEW STATE COUNTRY |
|
| 265 | + 'new_state_country' => new EE_Country_Select_Input( |
|
| 266 | + $country_options, |
|
| 267 | + array( |
|
| 268 | + 'html_name' => $country_name, |
|
| 269 | + 'html_id' => str_replace( |
|
| 270 | + 'state', |
|
| 271 | + 'nsmf_new_state_country', $input->html_id() |
|
| 272 | + ), |
|
| 273 | + 'html_class' => $input->html_class() . ' new-state-country', |
|
| 274 | + 'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'), |
|
| 275 | + 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
|
| 276 | + 'required' => false, |
|
| 277 | + ) |
|
| 278 | + ), |
|
| 279 | + // NEW STATE NAME |
|
| 280 | + 'new_state_name' => new EE_Text_Input( |
|
| 281 | + array( |
|
| 282 | + 'html_name' => $state_name, |
|
| 283 | + 'html_id' => str_replace( |
|
| 284 | + 'state', |
|
| 285 | + 'nsmf_new_state_name', $input->html_id() |
|
| 286 | + ), |
|
| 287 | + 'html_class' => $input->html_class() . ' new-state-state', |
|
| 288 | + 'html_label_text' => esc_html__('New State/Province Name', |
|
| 289 | + 'event_espresso'), |
|
| 290 | + 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
|
| 291 | + 'required' => false, |
|
| 292 | + ) |
|
| 293 | + ), |
|
| 294 | + 'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()), |
|
| 295 | + // NEW STATE NAME |
|
| 296 | + 'new_state_abbrv' => new EE_Text_Input( |
|
| 297 | + array( |
|
| 298 | + 'html_name' => $abbrv_name, |
|
| 299 | + 'html_id' => str_replace('state', 'nsmf_new_state_abbrv', |
|
| 300 | + $input->html_id()), |
|
| 301 | + 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
| 302 | + 'html_label_text' => esc_html__( |
|
| 303 | + 'New State/Province Abbreviation', |
|
| 304 | + 'event_espresso' |
|
| 305 | + ) . ' *', |
|
| 306 | + 'html_other_attributes' => 'size="24"', |
|
| 307 | + 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), |
|
| 308 | + 'required' => false, |
|
| 309 | + ) |
|
| 310 | + ), |
|
| 311 | + // "submit" button |
|
| 312 | + 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
|
| 313 | + apply_filters( |
|
| 314 | + 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
|
| 315 | + EEH_HTML::nbsp(3) . |
|
| 316 | + EEH_HTML::link( |
|
| 317 | + '', |
|
| 318 | + esc_html__('ADD', 'event_espresso'), |
|
| 319 | + '', |
|
| 320 | + 'submit-' . $new_state_submit_id, |
|
| 321 | + 'ee-form-add-new-state-submit button button-secondary', |
|
| 322 | + '', |
|
| 323 | + 'data-target="' . $new_state_submit_id . '"' |
|
| 324 | + ) |
|
| 325 | + ) |
|
| 326 | + ), |
|
| 327 | + // extra info |
|
| 328 | + 'add_new_state_extra' => new EE_Form_Section_HTML( |
|
| 329 | + apply_filters( |
|
| 330 | + 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra', |
|
| 331 | + EEH_HTML::br(2) |
|
| 332 | + . |
|
| 333 | + EEH_HTML::div('', '', 'small-text') |
|
| 334 | + . |
|
| 335 | + EEH_HTML::strong( |
|
| 336 | + '* ' . |
|
| 337 | + esc_html__( |
|
| 338 | + 'Don\'t know your State/Province Abbreviation?', |
|
| 339 | + 'event_espresso' |
|
| 340 | + ) |
|
| 341 | + ) |
|
| 342 | + . |
|
| 343 | + EEH_HTML::br() |
|
| 344 | + . |
|
| 345 | + sprintf( |
|
| 346 | + esc_html__( |
|
| 347 | + 'You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', |
|
| 348 | + 'event_espresso' |
|
| 349 | + ), |
|
| 350 | + EEH_HTML::link( |
|
| 351 | + 'http://en.wikipedia.org/wiki/ISO_3166-2', |
|
| 352 | + 'http://en.wikipedia.org/wiki/ISO_3166-2', |
|
| 353 | + '', |
|
| 354 | + '', |
|
| 355 | + 'ee-form-add-new-state-wiki-lnk', |
|
| 356 | + '', |
|
| 357 | + 'target="_blank"' |
|
| 358 | + ) |
|
| 359 | + ) |
|
| 360 | + . |
|
| 361 | + EEH_HTML::divx() |
|
| 362 | + . |
|
| 363 | + EEH_HTML::br() |
|
| 364 | + . |
|
| 365 | + EEH_HTML::link( |
|
| 366 | + '', |
|
| 367 | + esc_html__('cancel new State/Province', 'event_espresso'), |
|
| 368 | + '', |
|
| 369 | + 'hide-' . $input->html_id(), |
|
| 370 | + 'ee-form-cancel-new-state-lnk smaller-text', |
|
| 371 | + '', |
|
| 372 | + 'data-target="' . $input->html_id() . '"' |
|
| 373 | + ) |
|
| 374 | + . |
|
| 375 | + EEH_HTML::divx() |
|
| 376 | + . |
|
| 377 | + EEH_HTML::br() |
|
| 378 | + ) |
|
| 379 | + ), |
|
| 380 | + ), |
|
| 381 | + ) |
|
| 382 | + ); |
|
| 383 | + $question_group_reg_form->add_subsections( |
|
| 384 | + array('new_state_micro_form' => $new_state_micro_form), |
|
| 385 | + 'state', |
|
| 386 | + false |
|
| 387 | + ); |
|
| 388 | + } |
|
| 389 | + return $question_group_reg_form; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * set_new_state_input_width |
|
| 396 | + * |
|
| 397 | + * @return int|string |
|
| 398 | + * @throws EE_Error |
|
| 399 | + */ |
|
| 400 | + public static function add_new_state() |
|
| 401 | + { |
|
| 402 | + $REQ = EE_Registry::instance()->load_core('Request_Handler'); |
|
| 403 | + if (absint($REQ->get('nsmf_add_new_state')) === 1) { |
|
| 404 | + EE_Registry::instance()->load_model('State'); |
|
| 405 | + // grab country ISO code, new state name, and new state abbreviation |
|
| 406 | + $state_country = $REQ->is_set('nsmf_new_state_country') |
|
| 407 | + ? sanitize_text_field($REQ->get('nsmf_new_state_country')) |
|
| 408 | + : false; |
|
| 409 | + $state_name = $REQ->is_set('nsmf_new_state_name') |
|
| 410 | + ? sanitize_text_field($REQ->get('nsmf_new_state_name')) |
|
| 411 | + : false; |
|
| 412 | + $state_abbr = $REQ->is_set('nsmf_new_state_abbrv') |
|
| 413 | + ? sanitize_text_field($REQ->get('nsmf_new_state_abbrv')) |
|
| 414 | + : false; |
|
| 415 | + if ($state_country && $state_name && $state_abbr) { |
|
| 416 | + $new_state = EED_Add_New_State::save_new_state_to_db(array( |
|
| 417 | + 'CNT_ISO' => strtoupper($state_country), |
|
| 418 | + 'STA_abbrev' => strtoupper($state_abbr), |
|
| 419 | + 'STA_name' => ucwords($state_name), |
|
| 420 | + 'STA_active' => false, |
|
| 421 | + )); |
|
| 422 | + if ($new_state instanceof EE_State) { |
|
| 423 | + // clean house |
|
| 424 | + EE_Registry::instance()->REQ->un_set('nsmf_add_new_state'); |
|
| 425 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_country'); |
|
| 426 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_name'); |
|
| 427 | + EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv'); |
|
| 428 | + // get any existing new states |
|
| 429 | + $new_states = EE_Registry::instance()->SSN->get_session_data( |
|
| 430 | + 'nsmf_new_states' |
|
| 431 | + ); |
|
| 432 | + $new_states[$new_state->ID()] = $new_state; |
|
| 433 | + EE_Registry::instance()->SSN->set_session_data( |
|
| 434 | + array('nsmf_new_states' => $new_states) |
|
| 435 | + ); |
|
| 436 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 437 | + echo wp_json_encode(array( |
|
| 438 | + 'success' => true, |
|
| 439 | + 'id' => $new_state->ID(), |
|
| 440 | + 'name' => $new_state->name(), |
|
| 441 | + 'abbrev' => $new_state->abbrev(), |
|
| 442 | + 'country_iso' => $new_state->country_iso(), |
|
| 443 | + 'country_name' => $new_state->country()->name(), |
|
| 444 | + )); |
|
| 445 | + exit(); |
|
| 446 | + } |
|
| 447 | + return $new_state->ID(); |
|
| 448 | + } |
|
| 449 | + } else { |
|
| 450 | + $error = esc_html__( |
|
| 451 | + 'A new State/Province could not be added because invalid or missing data was received.', |
|
| 452 | + 'event_espresso' |
|
| 453 | + ); |
|
| 454 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 455 | + echo wp_json_encode(array('error' => $error)); |
|
| 456 | + exit(); |
|
| 457 | + } |
|
| 458 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 459 | + } |
|
| 460 | + } |
|
| 461 | + return false; |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + |
|
| 465 | + |
|
| 466 | + /** |
|
| 467 | + * recursively drills down through request params to remove any that were added by this module |
|
| 468 | + * |
|
| 469 | + * @param array $request_params |
|
| 470 | + * @return array |
|
| 471 | + */ |
|
| 472 | + public static function filter_checkout_request_params($request_params) |
|
| 473 | + { |
|
| 474 | + foreach ($request_params as $form_section) { |
|
| 475 | + if (is_array($form_section)) { |
|
| 476 | + EED_Add_New_State::unset_new_state_request_params($form_section); |
|
| 477 | + EED_Add_New_State::filter_checkout_request_params($form_section); |
|
| 478 | + } |
|
| 479 | + } |
|
| 480 | + return $request_params; |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * @param array $request_params |
|
| 487 | + * @return array |
|
| 488 | + */ |
|
| 489 | + public static function unset_new_state_request_params($request_params) |
|
| 490 | + { |
|
| 491 | + unset( |
|
| 492 | + $request_params['new_state_micro_form'], |
|
| 493 | + $request_params['new_state_micro_add_new_state'], |
|
| 494 | + $request_params['new_state_micro_new_state_country'], |
|
| 495 | + $request_params['new_state_micro_new_state_name'], |
|
| 496 | + $request_params['new_state_micro_new_state_abbrv'] |
|
| 497 | + ); |
|
| 498 | + return $request_params; |
|
| 499 | + } |
|
| 500 | + |
|
| 501 | + |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * @param array $props_n_values |
|
| 505 | + * @return bool |
|
| 506 | + * @throws EE_Error |
|
| 507 | + */ |
|
| 508 | + public static function save_new_state_to_db($props_n_values = array()) |
|
| 509 | + { |
|
| 510 | + $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
|
| 511 | + if (! empty($existing_state)) { |
|
| 512 | + return array_pop($existing_state); |
|
| 513 | + } |
|
| 514 | + $new_state = EE_State::new_instance($props_n_values); |
|
| 515 | + if ($new_state instanceof EE_State) { |
|
| 516 | + // if not non-ajax admin |
|
| 517 | + $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
| 518 | + $new_state_notice = sprintf( |
|
| 519 | + esc_html__( |
|
| 520 | + 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', |
|
| 521 | + 'event_espresso' |
|
| 522 | + ), |
|
| 523 | + '<b>' . $new_state->name() . '</b>', |
|
| 524 | + '<b>' . $new_state->abbrev() . '</b>', |
|
| 525 | + '<b>' . $new_state->country()->name() . '</b>', |
|
| 526 | + '<a href="' . add_query_arg(array( |
|
| 527 | + 'page' => 'espresso_general_settings', |
|
| 528 | + 'action' => 'country_settings', |
|
| 529 | + 'country' => $new_state->country_iso(), |
|
| 530 | + ), admin_url('admin.php')) . '">' . esc_html__('Event Espresso - General Settings > Countries Tab', |
|
| 531 | + 'event_espresso') . '</a>', |
|
| 532 | + '<br />' |
|
| 533 | + ); |
|
| 534 | + EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
|
| 535 | + $new_state->save(); |
|
| 536 | + EEM_State::instance()->reset_cached_states(); |
|
| 537 | + return $new_state; |
|
| 538 | + } |
|
| 539 | + return false; |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + |
|
| 543 | + |
|
| 544 | + /** |
|
| 545 | + * @param string $CNT_ISO |
|
| 546 | + * @param string $STA_ID |
|
| 547 | + * @param array $cols_n_values |
|
| 548 | + * @return void |
|
| 549 | + */ |
|
| 550 | + public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) |
|
| 551 | + { |
|
| 552 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false; |
|
| 553 | + if (! $CNT_ISO) { |
|
| 554 | + EE_Error::add_error( |
|
| 555 | + esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'), |
|
| 556 | + __FILE__, |
|
| 557 | + __FUNCTION__, |
|
| 558 | + __LINE__ |
|
| 559 | + ); |
|
| 560 | + } |
|
| 561 | + $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] |
|
| 562 | + : false; |
|
| 563 | + if (! $STA_abbrev && ! empty($STA_ID)) { |
|
| 564 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
| 565 | + if ($state instanceof EE_State) { |
|
| 566 | + $STA_abbrev = $state->abbrev(); |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + if (! $STA_abbrev) { |
|
| 570 | + EE_Error::add_error( |
|
| 571 | + esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'), |
|
| 572 | + __FILE__, |
|
| 573 | + __FUNCTION__, |
|
| 574 | + __LINE__ |
|
| 575 | + ); |
|
| 576 | + } |
|
| 577 | + EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true); |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + |
|
| 581 | + |
|
| 582 | + /** |
|
| 583 | + * @param EE_State[] $state_options |
|
| 584 | + * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
| 585 | + * @param EE_Registration $registration |
|
| 586 | + * @param EE_Question $question |
|
| 587 | + * @param $answer |
|
| 588 | + * @return array |
|
| 589 | + */ |
|
| 590 | + public static function inject_new_reg_state_into_options( |
|
| 591 | + $state_options = array(), |
|
| 592 | + EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
| 593 | + EE_Registration $registration, |
|
| 594 | + EE_Question $question, |
|
| 595 | + $answer |
|
| 596 | + ) { |
|
| 597 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question |
|
| 598 | + && $question->type() |
|
| 599 | + === EEM_Question::QST_type_state |
|
| 600 | + ) { |
|
| 601 | + $STA_ID = $answer->value(); |
|
| 602 | + if (! empty($STA_ID)) { |
|
| 603 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
| 604 | + if ($state instanceof EE_State) { |
|
| 605 | + $country = $state->country(); |
|
| 606 | + if ($country instanceof EE_Country) { |
|
| 607 | + if (! isset($state_options[$country->name()])) { |
|
| 608 | + $state_options[$country->name()] = array(); |
|
| 609 | + } |
|
| 610 | + if (! isset($state_options[$country->name()][$STA_ID])) { |
|
| 611 | + $state_options[$country->name()][$STA_ID] = $state->name(); |
|
| 612 | + } |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | + return $state_options; |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * @param EE_Country[] $country_options |
|
| 624 | + * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step |
|
| 625 | + * @param EE_Registration $registration |
|
| 626 | + * @param EE_Question $question |
|
| 627 | + * @param $answer |
|
| 628 | + * @return array |
|
| 629 | + */ |
|
| 630 | + public static function inject_new_reg_country_into_options( |
|
| 631 | + $country_options = array(), |
|
| 632 | + EE_SPCO_Reg_Step_Attendee_Information $reg_step, |
|
| 633 | + EE_Registration $registration, |
|
| 634 | + EE_Question $question, |
|
| 635 | + $answer |
|
| 636 | + ) { |
|
| 637 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question |
|
| 638 | + && $question->type() |
|
| 639 | + === EEM_Question::QST_type_country |
|
| 640 | + ) { |
|
| 641 | + $CNT_ISO = $answer->value(); |
|
| 642 | + if (! empty($CNT_ISO)) { |
|
| 643 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
| 644 | + if ($country instanceof EE_Country) { |
|
| 645 | + if (! isset($country_options[$CNT_ISO])) { |
|
| 646 | + $country_options[$CNT_ISO] = $country->name(); |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + return $country_options; |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * @param EE_State[] $state_options |
|
| 658 | + * @return array |
|
| 659 | + * @throws EE_Error |
|
| 660 | + */ |
|
| 661 | + public static function state_options($state_options = array()) |
|
| 662 | + { |
|
| 663 | + $new_states = EED_Add_New_State::_get_new_states(); |
|
| 664 | + foreach ($new_states as $new_state) { |
|
| 665 | + if ( |
|
| 666 | + $new_state instanceof EE_State |
|
| 667 | + && $new_state->country() instanceof EE_Country |
|
| 668 | + ) { |
|
| 669 | + $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name(); |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + return $state_options; |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + |
|
| 676 | + |
|
| 677 | + /** |
|
| 678 | + * @return array |
|
| 679 | + */ |
|
| 680 | + protected static function _get_new_states() |
|
| 681 | + { |
|
| 682 | + $new_states = array(); |
|
| 683 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 684 | + $new_states = EE_Registry::instance()->SSN->get_session_data( |
|
| 685 | + 'nsmf_new_states' |
|
| 686 | + ); |
|
| 687 | + } |
|
| 688 | + return is_array($new_states) ? $new_states : array(); |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + |
|
| 692 | + |
|
| 693 | + /** |
|
| 694 | + * @param EE_Country[] $country_options |
|
| 695 | + * @return array |
|
| 696 | + * @throws EE_Error |
|
| 697 | + */ |
|
| 698 | + public static function country_options($country_options = array()) |
|
| 699 | + { |
|
| 700 | + $new_states = EED_Add_New_State::_get_new_states(); |
|
| 701 | + foreach ($new_states as $new_state) { |
|
| 702 | + if ( |
|
| 703 | + $new_state instanceof EE_State |
|
| 704 | + && $new_state->country() instanceof EE_Country |
|
| 705 | + ) { |
|
| 706 | + $country_options[$new_state->country()->ID()] = $new_state->country()->name(); |
|
| 707 | + } |
|
| 708 | + } |
|
| 709 | + return $country_options; |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | 712 | |
| 713 | 713 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public static function set_definitions() |
| 95 | 95 | { |
| 96 | - define('ANS_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
| 96 | + define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
| 97 | 97 | define('ANS_TEMPLATES_PATH', str_replace( |
| 98 | 98 | '\\', |
| 99 | - DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
| 99 | + DS, plugin_dir_path(__FILE__)).'templates'.DS |
|
| 100 | 100 | ); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | public static function wp_enqueue_scripts() |
| 148 | 148 | { |
| 149 | 149 | if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
| 150 | - wp_register_script('add_new_state', ANS_ASSETS_URL . 'add_new_state.js', |
|
| 150 | + wp_register_script('add_new_state', ANS_ASSETS_URL.'add_new_state.js', |
|
| 151 | 151 | array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
| 152 | 152 | wp_enqueue_script('add_new_state'); |
| 153 | 153 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
| 188 | 188 | $country_options = array(); |
| 189 | 189 | $countries = EEM_Country::instance()->get_all_countries(); |
| 190 | - if (! empty($countries)) { |
|
| 190 | + if ( ! empty($countries)) { |
|
| 191 | 191 | foreach ($countries as $country) { |
| 192 | 192 | if ($country instanceof EE_Country) { |
| 193 | 193 | $country_options[$country->ID()] = $country->name(); |
@@ -222,10 +222,10 @@ discard block |
||
| 222 | 222 | '', |
| 223 | 223 | esc_html__('click here to add a new state/province', 'event_espresso'), |
| 224 | 224 | '', |
| 225 | - 'display-' . $input->html_id(), |
|
| 225 | + 'display-'.$input->html_id(), |
|
| 226 | 226 | 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
| 227 | 227 | '', |
| 228 | - 'data-target="' . $input->html_id() . '"' |
|
| 228 | + 'data-target="'.$input->html_id().'"' |
|
| 229 | 229 | ) |
| 230 | 230 | ) |
| 231 | 231 | ), |
@@ -233,31 +233,31 @@ discard block |
||
| 233 | 233 | 'add_new_state_micro_form' => new EE_Form_Section_HTML( |
| 234 | 234 | apply_filters( |
| 235 | 235 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
| 236 | - EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', |
|
| 237 | - 'display: none;') . |
|
| 236 | + EEH_HTML::div('', $input->html_id().'-dv', 'ee-form-add-new-state-dv', |
|
| 237 | + 'display: none;'). |
|
| 238 | 238 | EEH_HTML::h6( |
| 239 | 239 | esc_html__( |
| 240 | 240 | 'Is your state/province missing from the dropdown menu above? You can add it by completing the following steps:', |
| 241 | 241 | 'event_espresso' |
| 242 | 242 | ) |
| 243 | - ) . |
|
| 244 | - EEH_HTML::ul() . |
|
| 243 | + ). |
|
| 244 | + EEH_HTML::ul(). |
|
| 245 | 245 | EEH_HTML::li( |
| 246 | 246 | esc_html__( |
| 247 | 247 | 'first select the Country that your State/Province belongs to', |
| 248 | 248 | 'event_espresso' |
| 249 | 249 | ) |
| 250 | - ) . |
|
| 250 | + ). |
|
| 251 | 251 | EEH_HTML::li( |
| 252 | 252 | esc_html__('enter the name of your State/Province', 'event_espresso') |
| 253 | - ) . |
|
| 253 | + ). |
|
| 254 | 254 | EEH_HTML::li( |
| 255 | 255 | esc_html__( |
| 256 | 256 | 'enter a two to six letter abbreviation for the name of your State/Province', |
| 257 | 257 | 'event_espresso' |
| 258 | 258 | ) |
| 259 | - ) . |
|
| 260 | - EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')) . |
|
| 259 | + ). |
|
| 260 | + EEH_HTML::li(esc_html__('click the ADD button', 'event_espresso')). |
|
| 261 | 261 | EEH_HTML::ulx() |
| 262 | 262 | ) |
| 263 | 263 | ), |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | 'state', |
| 271 | 271 | 'nsmf_new_state_country', $input->html_id() |
| 272 | 272 | ), |
| 273 | - 'html_class' => $input->html_class() . ' new-state-country', |
|
| 273 | + 'html_class' => $input->html_class().' new-state-country', |
|
| 274 | 274 | 'html_label_text' => esc_html__('New State/Province Country', 'event_espresso'), |
| 275 | 275 | 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
| 276 | 276 | 'required' => false, |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | 'state', |
| 285 | 285 | 'nsmf_new_state_name', $input->html_id() |
| 286 | 286 | ), |
| 287 | - 'html_class' => $input->html_class() . ' new-state-state', |
|
| 287 | + 'html_class' => $input->html_class().' new-state-state', |
|
| 288 | 288 | 'html_label_text' => esc_html__('New State/Province Name', |
| 289 | 289 | 'event_espresso'), |
| 290 | 290 | 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
@@ -298,11 +298,11 @@ discard block |
||
| 298 | 298 | 'html_name' => $abbrv_name, |
| 299 | 299 | 'html_id' => str_replace('state', 'nsmf_new_state_abbrv', |
| 300 | 300 | $input->html_id()), |
| 301 | - 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
| 301 | + 'html_class' => $input->html_class().' new-state-abbrv', |
|
| 302 | 302 | 'html_label_text' => esc_html__( |
| 303 | 303 | 'New State/Province Abbreviation', |
| 304 | 304 | 'event_espresso' |
| 305 | - ) . ' *', |
|
| 305 | + ).' *', |
|
| 306 | 306 | 'html_other_attributes' => 'size="24"', |
| 307 | 307 | 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), |
| 308 | 308 | 'required' => false, |
@@ -312,15 +312,15 @@ discard block |
||
| 312 | 312 | 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
| 313 | 313 | apply_filters( |
| 314 | 314 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
| 315 | - EEH_HTML::nbsp(3) . |
|
| 315 | + EEH_HTML::nbsp(3). |
|
| 316 | 316 | EEH_HTML::link( |
| 317 | 317 | '', |
| 318 | 318 | esc_html__('ADD', 'event_espresso'), |
| 319 | 319 | '', |
| 320 | - 'submit-' . $new_state_submit_id, |
|
| 320 | + 'submit-'.$new_state_submit_id, |
|
| 321 | 321 | 'ee-form-add-new-state-submit button button-secondary', |
| 322 | 322 | '', |
| 323 | - 'data-target="' . $new_state_submit_id . '"' |
|
| 323 | + 'data-target="'.$new_state_submit_id.'"' |
|
| 324 | 324 | ) |
| 325 | 325 | ) |
| 326 | 326 | ), |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | EEH_HTML::div('', '', 'small-text') |
| 334 | 334 | . |
| 335 | 335 | EEH_HTML::strong( |
| 336 | - '* ' . |
|
| 336 | + '* '. |
|
| 337 | 337 | esc_html__( |
| 338 | 338 | 'Don\'t know your State/Province Abbreviation?', |
| 339 | 339 | 'event_espresso' |
@@ -366,10 +366,10 @@ discard block |
||
| 366 | 366 | '', |
| 367 | 367 | esc_html__('cancel new State/Province', 'event_espresso'), |
| 368 | 368 | '', |
| 369 | - 'hide-' . $input->html_id(), |
|
| 369 | + 'hide-'.$input->html_id(), |
|
| 370 | 370 | 'ee-form-cancel-new-state-lnk smaller-text', |
| 371 | 371 | '', |
| 372 | - 'data-target="' . $input->html_id() . '"' |
|
| 372 | + 'data-target="'.$input->html_id().'"' |
|
| 373 | 373 | ) |
| 374 | 374 | . |
| 375 | 375 | EEH_HTML::divx() |
@@ -508,27 +508,27 @@ discard block |
||
| 508 | 508 | public static function save_new_state_to_db($props_n_values = array()) |
| 509 | 509 | { |
| 510 | 510 | $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
| 511 | - if (! empty($existing_state)) { |
|
| 511 | + if ( ! empty($existing_state)) { |
|
| 512 | 512 | return array_pop($existing_state); |
| 513 | 513 | } |
| 514 | 514 | $new_state = EE_State::new_instance($props_n_values); |
| 515 | 515 | if ($new_state instanceof EE_State) { |
| 516 | 516 | // if not non-ajax admin |
| 517 | - $new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
| 517 | + $new_state_key = 'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev(); |
|
| 518 | 518 | $new_state_notice = sprintf( |
| 519 | 519 | esc_html__( |
| 520 | 520 | 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', |
| 521 | 521 | 'event_espresso' |
| 522 | 522 | ), |
| 523 | - '<b>' . $new_state->name() . '</b>', |
|
| 524 | - '<b>' . $new_state->abbrev() . '</b>', |
|
| 525 | - '<b>' . $new_state->country()->name() . '</b>', |
|
| 526 | - '<a href="' . add_query_arg(array( |
|
| 523 | + '<b>'.$new_state->name().'</b>', |
|
| 524 | + '<b>'.$new_state->abbrev().'</b>', |
|
| 525 | + '<b>'.$new_state->country()->name().'</b>', |
|
| 526 | + '<a href="'.add_query_arg(array( |
|
| 527 | 527 | 'page' => 'espresso_general_settings', |
| 528 | 528 | 'action' => 'country_settings', |
| 529 | 529 | 'country' => $new_state->country_iso(), |
| 530 | - ), admin_url('admin.php')) . '">' . esc_html__('Event Espresso - General Settings > Countries Tab', |
|
| 531 | - 'event_espresso') . '</a>', |
|
| 530 | + ), admin_url('admin.php')).'">'.esc_html__('Event Espresso - General Settings > Countries Tab', |
|
| 531 | + 'event_espresso').'</a>', |
|
| 532 | 532 | '<br />' |
| 533 | 533 | ); |
| 534 | 534 | EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) |
| 551 | 551 | { |
| 552 | 552 | $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : false; |
| 553 | - if (! $CNT_ISO) { |
|
| 553 | + if ( ! $CNT_ISO) { |
|
| 554 | 554 | EE_Error::add_error( |
| 555 | 555 | esc_html__('An invalid or missing Country ISO Code was received.', 'event_espresso'), |
| 556 | 556 | __FILE__, |
@@ -560,13 +560,13 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] |
| 562 | 562 | : false; |
| 563 | - if (! $STA_abbrev && ! empty($STA_ID)) { |
|
| 563 | + if ( ! $STA_abbrev && ! empty($STA_ID)) { |
|
| 564 | 564 | $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
| 565 | 565 | if ($state instanceof EE_State) { |
| 566 | 566 | $STA_abbrev = $state->abbrev(); |
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | - if (! $STA_abbrev) { |
|
| 569 | + if ( ! $STA_abbrev) { |
|
| 570 | 570 | EE_Error::add_error( |
| 571 | 571 | esc_html__('An invalid or missing State Abbreviation was received.', 'event_espresso'), |
| 572 | 572 | __FILE__, |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | __LINE__ |
| 575 | 575 | ); |
| 576 | 576 | } |
| 577 | - EE_Error::dismiss_persistent_admin_notice($CNT_ISO . '-' . $STA_abbrev, true, true); |
|
| 577 | + EE_Error::dismiss_persistent_admin_notice($CNT_ISO.'-'.$STA_abbrev, true, true); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | |
@@ -599,15 +599,15 @@ discard block |
||
| 599 | 599 | === EEM_Question::QST_type_state |
| 600 | 600 | ) { |
| 601 | 601 | $STA_ID = $answer->value(); |
| 602 | - if (! empty($STA_ID)) { |
|
| 602 | + if ( ! empty($STA_ID)) { |
|
| 603 | 603 | $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
| 604 | 604 | if ($state instanceof EE_State) { |
| 605 | 605 | $country = $state->country(); |
| 606 | 606 | if ($country instanceof EE_Country) { |
| 607 | - if (! isset($state_options[$country->name()])) { |
|
| 607 | + if ( ! isset($state_options[$country->name()])) { |
|
| 608 | 608 | $state_options[$country->name()] = array(); |
| 609 | 609 | } |
| 610 | - if (! isset($state_options[$country->name()][$STA_ID])) { |
|
| 610 | + if ( ! isset($state_options[$country->name()][$STA_ID])) { |
|
| 611 | 611 | $state_options[$country->name()][$STA_ID] = $state->name(); |
| 612 | 612 | } |
| 613 | 613 | } |
@@ -639,10 +639,10 @@ discard block |
||
| 639 | 639 | === EEM_Question::QST_type_country |
| 640 | 640 | ) { |
| 641 | 641 | $CNT_ISO = $answer->value(); |
| 642 | - if (! empty($CNT_ISO)) { |
|
| 642 | + if ( ! empty($CNT_ISO)) { |
|
| 643 | 643 | $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
| 644 | 644 | if ($country instanceof EE_Country) { |
| 645 | - if (! isset($country_options[$CNT_ISO])) { |
|
| 645 | + if ( ! isset($country_options[$CNT_ISO])) { |
|
| 646 | 646 | $country_options[$CNT_ISO] = $country->name(); |
| 647 | 647 | } |
| 648 | 648 | } |
@@ -286,41 +286,41 @@ discard block |
||
| 286 | 286 | $this->checkout->revisit |
| 287 | 287 | ); |
| 288 | 288 | foreach ( $registrations as $REG_ID => $registration ) { |
| 289 | - /** @var $registration EE_Registration */ |
|
| 290 | - // has this registration lost it's space ? |
|
| 289 | + /** @var $registration EE_Registration */ |
|
| 290 | + // has this registration lost it's space ? |
|
| 291 | 291 | if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
| 292 | 292 | $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
| 293 | 293 | continue; |
| 294 | 294 | } |
| 295 | - // event requires admin approval |
|
| 296 | - if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
| 297 | - // add event to list of events with pre-approval reg status |
|
| 298 | - $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
| 299 | - do_action( |
|
| 300 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
| 301 | - $registration->event(), |
|
| 302 | - $this |
|
| 303 | - ); |
|
| 304 | - continue; |
|
| 305 | - } |
|
| 306 | - if ( |
|
| 295 | + // event requires admin approval |
|
| 296 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
| 297 | + // add event to list of events with pre-approval reg status |
|
| 298 | + $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
| 299 | + do_action( |
|
| 300 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
| 301 | + $registration->event(), |
|
| 302 | + $this |
|
| 303 | + ); |
|
| 304 | + continue; |
|
| 305 | + } |
|
| 306 | + if ( |
|
| 307 | 307 | // returning registrant |
| 308 | 308 | $this->checkout->revisit |
| 309 | 309 | // anything other than Approved |
| 310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_approved |
| 311 | - && ( |
|
| 312 | - $registration->event()->is_sold_out() |
|
| 313 | - || $registration->event()->is_sold_out( true ) |
|
| 314 | - ) |
|
| 315 | - ) { |
|
| 316 | - // add event to list of events that are sold out |
|
| 317 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 318 | - do_action( |
|
| 319 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
| 320 | - $registration->event(), |
|
| 321 | - $this |
|
| 322 | - ); |
|
| 323 | - continue; |
|
| 311 | + && ( |
|
| 312 | + $registration->event()->is_sold_out() |
|
| 313 | + || $registration->event()->is_sold_out( true ) |
|
| 314 | + ) |
|
| 315 | + ) { |
|
| 316 | + // add event to list of events that are sold out |
|
| 317 | + $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 318 | + do_action( |
|
| 319 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
| 320 | + $registration->event(), |
|
| 321 | + $this |
|
| 322 | + ); |
|
| 323 | + continue; |
|
| 324 | 324 | } |
| 325 | 325 | // are they allowed to pay now and is there monies owing? |
| 326 | 326 | if ( $registration->owes_monies_and_can_pay() ) { |
@@ -428,11 +428,11 @@ discard block |
||
| 428 | 428 | new EE_Billable_Line_Item_Filter( |
| 429 | 429 | EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations( |
| 430 | 430 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
| 431 | - EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
| 432 | - ) |
|
| 431 | + EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
| 432 | + ) |
|
| 433 | 433 | ) |
| 434 | 434 | ) |
| 435 | - ); |
|
| 435 | + ); |
|
| 436 | 436 | $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
| 437 | 437 | return $line_item_filter_collection; |
| 438 | 438 | } |
@@ -481,46 +481,46 @@ discard block |
||
| 481 | 481 | * @throws \EE_Error |
| 482 | 482 | */ |
| 483 | 483 | public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
| 484 | - // registrations per event |
|
| 484 | + // registrations per event |
|
| 485 | 485 | $event_reg_count = array(); |
| 486 | 486 | // spaces left per event |
| 487 | 487 | $event_spaces_remaining = array(); |
| 488 | - // tickets left sorted by ID |
|
| 489 | - $tickets_remaining = array(); |
|
| 490 | - // registrations that have lost their space |
|
| 488 | + // tickets left sorted by ID |
|
| 489 | + $tickets_remaining = array(); |
|
| 490 | + // registrations that have lost their space |
|
| 491 | 491 | $ejected_registrations = array(); |
| 492 | 492 | foreach ( $registrations as $REG_ID => $registration ) { |
| 493 | - if ( |
|
| 494 | - $registration->status_ID() === EEM_Registration::status_id_approved |
|
| 495 | - || apply_filters( |
|
| 496 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
| 497 | - false, |
|
| 498 | - $registration, |
|
| 499 | - $revisit |
|
| 500 | - ) |
|
| 501 | - ) { |
|
| 502 | - continue; |
|
| 493 | + if ( |
|
| 494 | + $registration->status_ID() === EEM_Registration::status_id_approved |
|
| 495 | + || apply_filters( |
|
| 496 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
| 497 | + false, |
|
| 498 | + $registration, |
|
| 499 | + $revisit |
|
| 500 | + ) |
|
| 501 | + ) { |
|
| 502 | + continue; |
|
| 503 | 503 | } |
| 504 | 504 | $EVT_ID = $registration->event_ID(); |
| 505 | - $ticket = $registration->ticket(); |
|
| 506 | - if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
| 507 | - $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
| 508 | - } |
|
| 509 | - if ($tickets_remaining[$ticket->ID()] > 0) { |
|
| 510 | - if ( ! isset($event_reg_count[$EVT_ID])) { |
|
| 511 | - $event_reg_count[$EVT_ID] = 0; |
|
| 512 | - } |
|
| 513 | - $event_reg_count[$EVT_ID]++; |
|
| 514 | - if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
| 515 | - $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
| 516 | - } |
|
| 517 | - } |
|
| 505 | + $ticket = $registration->ticket(); |
|
| 506 | + if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
| 507 | + $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
| 508 | + } |
|
| 509 | + if ($tickets_remaining[$ticket->ID()] > 0) { |
|
| 510 | + if ( ! isset($event_reg_count[$EVT_ID])) { |
|
| 511 | + $event_reg_count[$EVT_ID] = 0; |
|
| 512 | + } |
|
| 513 | + $event_reg_count[$EVT_ID]++; |
|
| 514 | + if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
| 515 | + $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
| 516 | + } |
|
| 517 | + } |
|
| 518 | 518 | if ( |
| 519 | 519 | $revisit |
| 520 | 520 | && ( |
| 521 | - $tickets_remaining[$ticket->ID()] === 0 |
|
| 522 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
| 523 | - ) |
|
| 521 | + $tickets_remaining[$ticket->ID()] === 0 |
|
| 522 | + || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
| 523 | + ) |
|
| 524 | 524 | ) { |
| 525 | 525 | $ejected_registrations[ $REG_ID ] = $registration->event(); |
| 526 | 526 | if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
@@ -589,9 +589,9 @@ discard block |
||
| 589 | 589 | 'layout_strategy' => new EE_Template_Layout( |
| 590 | 590 | array( |
| 591 | 591 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
| 592 | - . $this->_slug |
|
| 593 | - . DS |
|
| 594 | - . 'sold_out_events.template.php', |
|
| 592 | + . $this->_slug |
|
| 593 | + . DS |
|
| 594 | + . 'sold_out_events.template.php', |
|
| 595 | 595 | 'template_args' => apply_filters( |
| 596 | 596 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
| 597 | 597 | array( |
@@ -644,9 +644,9 @@ discard block |
||
| 644 | 644 | 'layout_strategy' => new EE_Template_Layout( |
| 645 | 645 | array( |
| 646 | 646 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
| 647 | - . $this->_slug |
|
| 648 | - . DS |
|
| 649 | - . 'sold_out_events.template.php', |
|
| 647 | + . $this->_slug |
|
| 648 | + . DS |
|
| 649 | + . 'sold_out_events.template.php', |
|
| 650 | 650 | 'template_args' => apply_filters( |
| 651 | 651 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args', |
| 652 | 652 | array( |
@@ -694,9 +694,9 @@ discard block |
||
| 694 | 694 | 'layout_strategy' => new EE_Template_Layout( |
| 695 | 695 | array( |
| 696 | 696 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
| 697 | - . $this->_slug |
|
| 698 | - . DS |
|
| 699 | - . 'events_requiring_pre_approval.template.php', // layout_template |
|
| 697 | + . $this->_slug |
|
| 698 | + . DS |
|
| 699 | + . 'events_requiring_pre_approval.template.php', // layout_template |
|
| 700 | 700 | 'template_args' => apply_filters( |
| 701 | 701 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
| 702 | 702 | array( |
@@ -734,9 +734,9 @@ discard block |
||
| 734 | 734 | 'layout_strategy' => new EE_Template_Layout( |
| 735 | 735 | array( |
| 736 | 736 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
| 737 | - . $this->_slug |
|
| 738 | - . DS |
|
| 739 | - . 'no_payment_required.template.php', // layout_template |
|
| 737 | + . $this->_slug |
|
| 738 | + . DS |
|
| 739 | + . 'no_payment_required.template.php', // layout_template |
|
| 740 | 740 | 'template_args' => apply_filters( |
| 741 | 741 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
| 742 | 742 | array( |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
| 965 | 965 | } |
| 966 | 966 | $payment_methods_billing_info[ $payment_method->slug() |
| 967 | - . '-info' ] = $this->_payment_method_billing_info( |
|
| 967 | + . '-info' ] = $this->_payment_method_billing_info( |
|
| 968 | 968 | $payment_method |
| 969 | 969 | ); |
| 970 | 970 | } |
@@ -1152,7 +1152,7 @@ discard block |
||
| 1152 | 1152 | // fill form with attendee info if applicable |
| 1153 | 1153 | if ( |
| 1154 | 1154 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
| 1155 | - && $this->checkout->transaction_has_primary_registrant() |
|
| 1155 | + && $this->checkout->transaction_has_primary_registrant() |
|
| 1156 | 1156 | ) { |
| 1157 | 1157 | $payment_method_billing_form->populate_from_attendee( |
| 1158 | 1158 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | // and debug content |
| 1162 | 1162 | if ( |
| 1163 | 1163 | $payment_method_billing_form instanceof EE_Billing_Info_Form |
| 1164 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
| 1164 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
| 1165 | 1165 | ) { |
| 1166 | 1166 | $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
| 1167 | 1167 | $payment_method_billing_form |
@@ -1336,7 +1336,7 @@ discard block |
||
| 1336 | 1336 | } |
| 1337 | 1337 | // and debug content |
| 1338 | 1338 | if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
| 1339 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
| 1339 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
| 1340 | 1340 | ) { |
| 1341 | 1341 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
| 1342 | 1342 | $this->checkout->billing_form |
@@ -1506,8 +1506,8 @@ discard block |
||
| 1506 | 1506 | } |
| 1507 | 1507 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
| 1508 | 1508 | if ( ! empty( $attendee_data['ATT_fname'] ) |
| 1509 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
| 1510 | - && ! empty( $attendee_data['ATT_email'] ) |
|
| 1509 | + && ! empty( $attendee_data['ATT_lname'] ) |
|
| 1510 | + && ! empty( $attendee_data['ATT_email'] ) |
|
| 1511 | 1511 | ) { |
| 1512 | 1512 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
| 1513 | 1513 | array( |
@@ -1754,7 +1754,7 @@ discard block |
||
| 1754 | 1754 | $payment_status = $payment->status(); |
| 1755 | 1755 | if ( |
| 1756 | 1756 | $payment_status === EEM_Payment::status_id_approved |
| 1757 | - || $payment_status === EEM_Payment::status_id_pending |
|
| 1757 | + || $payment_status === EEM_Payment::status_id_pending |
|
| 1758 | 1758 | ) { |
| 1759 | 1759 | return true; |
| 1760 | 1760 | } else { |
@@ -1980,8 +1980,8 @@ discard block |
||
| 1980 | 1980 | return false; |
| 1981 | 1981 | } |
| 1982 | 1982 | if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
| 1983 | - instanceof |
|
| 1984 | - EE_Attendee |
|
| 1983 | + instanceof |
|
| 1984 | + EE_Attendee |
|
| 1985 | 1985 | ) { |
| 1986 | 1986 | EE_Error::add_error( |
| 1987 | 1987 | sprintf( |
@@ -2454,14 +2454,14 @@ discard block |
||
| 2454 | 2454 | |
| 2455 | 2455 | |
| 2456 | 2456 | |
| 2457 | - /** |
|
| 2458 | - * _validate_return |
|
| 2459 | - * |
|
| 2460 | - * @access private |
|
| 2461 | - * @return void |
|
| 2462 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 2463 | - * @throws \EE_Error |
|
| 2464 | - */ |
|
| 2457 | + /** |
|
| 2458 | + * _validate_return |
|
| 2459 | + * |
|
| 2460 | + * @access private |
|
| 2461 | + * @return void |
|
| 2462 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 2463 | + * @throws \EE_Error |
|
| 2464 | + */ |
|
| 2465 | 2465 | private function _validate_offsite_return() { |
| 2466 | 2466 | $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
| 2467 | 2467 | if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
@@ -2487,20 +2487,20 @@ discard block |
||
| 2487 | 2487 | ? $primary_registrant->session_ID() |
| 2488 | 2488 | : null; |
| 2489 | 2489 | // validate current Session ID and compare against valid TXN session ID |
| 2490 | - if ( |
|
| 2491 | - $invalid_TXN // if this is already true, then skip other checks |
|
| 2492 | - || EE_Session::instance()->id() === null |
|
| 2493 | - || ( |
|
| 2494 | - // WARNING !!! |
|
| 2495 | - // this could be PayPal sending back duplicate requests (ya they do that) |
|
| 2496 | - // or it **could** mean someone is simply registering AGAIN after having just done so |
|
| 2497 | - // so now we need to determine if this current TXN looks valid or not |
|
| 2498 | - // and whether this reg step has even been started ? |
|
| 2499 | - EE_Session::instance()->id() === $valid_TXN_SID |
|
| 2500 | - // really? you're half way through this reg step, but you never started it ? |
|
| 2501 | - && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
| 2502 | - ) |
|
| 2503 | - ) { |
|
| 2490 | + if ( |
|
| 2491 | + $invalid_TXN // if this is already true, then skip other checks |
|
| 2492 | + || EE_Session::instance()->id() === null |
|
| 2493 | + || ( |
|
| 2494 | + // WARNING !!! |
|
| 2495 | + // this could be PayPal sending back duplicate requests (ya they do that) |
|
| 2496 | + // or it **could** mean someone is simply registering AGAIN after having just done so |
|
| 2497 | + // so now we need to determine if this current TXN looks valid or not |
|
| 2498 | + // and whether this reg step has even been started ? |
|
| 2499 | + EE_Session::instance()->id() === $valid_TXN_SID |
|
| 2500 | + // really? you're half way through this reg step, but you never started it ? |
|
| 2501 | + && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
| 2502 | + ) |
|
| 2503 | + ) { |
|
| 2504 | 2504 | $invalid_TXN = true; |
| 2505 | 2505 | } |
| 2506 | 2506 | if ( $invalid_TXN ) { |
@@ -2702,19 +2702,19 @@ discard block |
||
| 2702 | 2702 | |
| 2703 | 2703 | |
| 2704 | 2704 | |
| 2705 | - /** |
|
| 2706 | - * __sleep |
|
| 2707 | - * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization |
|
| 2708 | - * EE_Checkout will handle the reimplementation of itself upon waking, |
|
| 2709 | - * but we won't bother with the reg form, because if needed, it will be regenerated anyways |
|
| 2710 | - * |
|
| 2711 | - * @return array |
|
| 2712 | - */ |
|
| 2713 | - public function __sleep() |
|
| 2714 | - { |
|
| 2715 | - // remove the reg form and the checkout |
|
| 2716 | - return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
| 2717 | - } |
|
| 2705 | + /** |
|
| 2706 | + * __sleep |
|
| 2707 | + * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization |
|
| 2708 | + * EE_Checkout will handle the reimplementation of itself upon waking, |
|
| 2709 | + * but we won't bother with the reg form, because if needed, it will be regenerated anyways |
|
| 2710 | + * |
|
| 2711 | + * @return array |
|
| 2712 | + */ |
|
| 2713 | + public function __sleep() |
|
| 2714 | + { |
|
| 2715 | + // remove the reg form and the checkout |
|
| 2716 | + return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
| 2717 | + } |
|
| 2718 | 2718 | |
| 2719 | 2719 | |
| 2720 | 2720 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -38,32 +38,32 @@ discard block |
||
| 38 | 38 | public static function set_hooks() { |
| 39 | 39 | add_filter( |
| 40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
| 41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
| 41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
| 42 | 42 | ); |
| 43 | 43 | add_action( |
| 44 | 44 | 'wp_ajax_switch_spco_billing_form', |
| 45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
| 45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
| 46 | 46 | ); |
| 47 | 47 | add_action( |
| 48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
| 49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
| 49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
| 50 | 50 | ); |
| 51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
| 51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
| 52 | 52 | add_action( |
| 53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
| 54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
| 54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
| 55 | 55 | ); |
| 56 | 56 | add_action( |
| 57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
| 58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
| 58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
| 59 | 59 | ); |
| 60 | 60 | add_action( |
| 61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
| 62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
| 62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
| 63 | 63 | ); |
| 64 | 64 | add_filter( |
| 65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
| 66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
| 66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
| 67 | 67 | 10, |
| 68 | 68 | 1 |
| 69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @throws \EE_Error |
| 78 | 78 | */ |
| 79 | 79 | public static function switch_spco_billing_form() { |
| 80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
| 80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @throws \EE_Error |
| 89 | 89 | */ |
| 90 | 90 | public static function save_payer_details() { |
| 91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
| 91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @throws \EE_Error |
| 100 | 100 | */ |
| 101 | 101 | public static function get_transaction_details() { |
| 102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
| 102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | * @access public |
| 127 | 127 | * @param EE_Checkout $checkout |
| 128 | 128 | */ |
| 129 | - public function __construct( EE_Checkout $checkout ) { |
|
| 129 | + public function __construct(EE_Checkout $checkout) { |
|
| 130 | 130 | $this->_slug = 'payment_options'; |
| 131 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
| 132 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
| 131 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
| 132 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
| 133 | 133 | $this->checkout = $checkout; |
| 134 | 134 | $this->_reset_success_message(); |
| 135 | 135 | $this->set_instructions( |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | /** |
| 155 | 155 | * @param null $line_item_display |
| 156 | 156 | */ |
| 157 | - public function set_line_item_display( $line_item_display ) { |
|
| 157 | + public function set_line_item_display($line_item_display) { |
|
| 158 | 158 | $this->line_item_display = $line_item_display; |
| 159 | 159 | } |
| 160 | 160 | |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | /** |
| 173 | 173 | * @param boolean $handle_IPN_in_this_request |
| 174 | 174 | */ |
| 175 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
| 176 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
| 175 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
| 176 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | public function enqueue_styles_and_scripts() { |
| 209 | 209 | $transaction = $this->checkout->transaction; |
| 210 | 210 | //if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
| 211 | - if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) { |
|
| 211 | + if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
| 212 | 212 | return; |
| 213 | 213 | } |
| 214 | - foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) { |
|
| 214 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) { |
|
| 215 | 215 | $type_obj = $payment_method->type_obj(); |
| 216 | - if( $type_obj instanceof EE_PMT_Base ) { |
|
| 217 | - $billing_form = $type_obj->generate_new_billing_form( $transaction ); |
|
| 218 | - if( $billing_form instanceof EE_Form_Section_Proper ) { |
|
| 216 | + if ($type_obj instanceof EE_PMT_Base) { |
|
| 217 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
| 218 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 219 | 219 | $billing_form->enqueue_js(); |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -240,20 +240,20 @@ discard block |
||
| 240 | 240 | // $ 0.00 transactions (no payment required) |
| 241 | 241 | ! $this->checkout->payment_required() |
| 242 | 242 | // but do NOT remove if current action being called belongs to this reg step |
| 243 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
| 243 | + && ! is_callable(array($this, $this->checkout->action)) |
|
| 244 | 244 | && ! $this->completed() |
| 245 | 245 | ) { |
| 246 | 246 | // and if so, then we no longer need the Payment Options step |
| 247 | - if ( $this->is_current_step() ) { |
|
| 247 | + if ($this->is_current_step()) { |
|
| 248 | 248 | $this->checkout->generate_reg_form = false; |
| 249 | 249 | } |
| 250 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
| 250 | + $this->checkout->remove_reg_step($this->_slug); |
|
| 251 | 251 | // DEBUG LOG |
| 252 | 252 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
| 253 | 253 | return false; |
| 254 | 254 | } |
| 255 | 255 | // load EEM_Payment_Method |
| 256 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
| 256 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 257 | 257 | // get all active payment methods |
| 258 | 258 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
| 259 | 259 | $this->checkout->transaction, |
@@ -280,16 +280,16 @@ discard block |
||
| 280 | 280 | $insufficient_spaces_available = array(); |
| 281 | 281 | $no_payment_required = true; |
| 282 | 282 | // loop thru registrations to gather info |
| 283 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
| 283 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 284 | 284 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
| 285 | 285 | $registrations, |
| 286 | 286 | $this->checkout->revisit |
| 287 | 287 | ); |
| 288 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
| 288 | + foreach ($registrations as $REG_ID => $registration) { |
|
| 289 | 289 | /** @var $registration EE_Registration */ |
| 290 | 290 | // has this registration lost it's space ? |
| 291 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
| 292 | - $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
| 291 | + if (isset($ejected_registrations[$REG_ID])) { |
|
| 292 | + $insufficient_spaces_available[$registration->event()->ID()] = $registration->event(); |
|
| 293 | 293 | continue; |
| 294 | 294 | } |
| 295 | 295 | // event requires admin approval |
@@ -310,11 +310,11 @@ discard block |
||
| 310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_approved |
| 311 | 311 | && ( |
| 312 | 312 | $registration->event()->is_sold_out() |
| 313 | - || $registration->event()->is_sold_out( true ) |
|
| 313 | + || $registration->event()->is_sold_out(true) |
|
| 314 | 314 | ) |
| 315 | 315 | ) { |
| 316 | 316 | // add event to list of events that are sold out |
| 317 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 317 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
| 318 | 318 | do_action( |
| 319 | 319 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
| 320 | 320 | $registration->event(), |
@@ -323,8 +323,8 @@ discard block |
||
| 323 | 323 | continue; |
| 324 | 324 | } |
| 325 | 325 | // are they allowed to pay now and is there monies owing? |
| 326 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
| 327 | - $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
| 326 | + if ($registration->owes_monies_and_can_pay()) { |
|
| 327 | + $registrations_requiring_payment[$REG_ID] = $registration; |
|
| 328 | 328 | do_action( |
| 329 | 329 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
| 330 | 330 | $registration->event(), |
@@ -335,29 +335,29 @@ discard block |
||
| 335 | 335 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
| 336 | 336 | && $registration->ticket()->is_free() |
| 337 | 337 | ) { |
| 338 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
| 338 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | $subsections = array(); |
| 342 | 342 | // now decide which template to load |
| 343 | - if ( ! empty( $sold_out_events ) ) { |
|
| 344 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
| 343 | + if ( ! empty($sold_out_events)) { |
|
| 344 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
| 345 | 345 | } |
| 346 | - if ( ! empty( $insufficient_spaces_available ) ) { |
|
| 346 | + if ( ! empty($insufficient_spaces_available)) { |
|
| 347 | 347 | $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
| 348 | 348 | $insufficient_spaces_available |
| 349 | 349 | ); |
| 350 | 350 | } |
| 351 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
| 351 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
| 352 | 352 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
| 353 | 353 | $registrations_requiring_pre_approval |
| 354 | 354 | ); |
| 355 | 355 | } |
| 356 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
| 357 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
| 356 | + if ( ! empty($registrations_for_free_events)) { |
|
| 357 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
| 358 | 358 | } |
| 359 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
| 360 | - if ( $this->checkout->amount_owing > 0 ) { |
|
| 359 | + if ( ! empty($registrations_requiring_payment)) { |
|
| 360 | + if ($this->checkout->amount_owing > 0) { |
|
| 361 | 361 | // autoload Line_Item_Display classes |
| 362 | 362 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
| 363 | 363 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -370,15 +370,15 @@ discard block |
||
| 370 | 370 | /** @var EE_Line_Item $filtered_line_item_tree */ |
| 371 | 371 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
| 372 | 372 | EEH_Autoloader::register_line_item_display_autoloaders(); |
| 373 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
| 373 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
| 374 | 374 | $subsections['payment_options'] = $this->_display_payment_options( |
| 375 | 375 | $this->line_item_display->display_line_item( |
| 376 | 376 | $filtered_line_item_tree, |
| 377 | - array( 'registrations' => $registrations ) |
|
| 377 | + array('registrations' => $registrations) |
|
| 378 | 378 | ) |
| 379 | 379 | ); |
| 380 | 380 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
| 381 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
| 381 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
| 382 | 382 | } |
| 383 | 383 | $no_payment_required = false; |
| 384 | 384 | } else { |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | $this->_save_selected_method_of_payment(); |
| 388 | 388 | |
| 389 | 389 | $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs(); |
| 390 | - $subsections['extra_hidden_inputs' ] = $this->_extra_hidden_inputs( $no_payment_required ); |
|
| 390 | + $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required); |
|
| 391 | 391 | |
| 392 | 392 | return new EE_Form_Section_Proper( |
| 393 | 393 | array( |
@@ -414,14 +414,14 @@ discard block |
||
| 414 | 414 | * @return \EE_Line_Item_Filter_Collection |
| 415 | 415 | * @throws \EE_Error |
| 416 | 416 | */ |
| 417 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
| 418 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
| 417 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
| 418 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 419 | 419 | return $line_item_filter_collection; |
| 420 | 420 | } |
| 421 | - if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout ) { |
|
| 421 | + if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
| 422 | 422 | return $line_item_filter_collection; |
| 423 | 423 | } |
| 424 | - if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction ) { |
|
| 424 | + if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
| 425 | 425 | return $line_item_filter_collection; |
| 426 | 426 | } |
| 427 | 427 | $line_item_filter_collection->add( |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | ) |
| 434 | 434 | ) |
| 435 | 435 | ); |
| 436 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
| 436 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
| 437 | 437 | return $line_item_filter_collection; |
| 438 | 438 | } |
| 439 | 439 | |
@@ -449,15 +449,15 @@ discard block |
||
| 449 | 449 | * @return \EE_Registration[] |
| 450 | 450 | * @throws \EE_Error |
| 451 | 451 | */ |
| 452 | - public static function remove_ejected_registrations( array $registrations ) { |
|
| 452 | + public static function remove_ejected_registrations(array $registrations) { |
|
| 453 | 453 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
| 454 | 454 | $registrations, |
| 455 | 455 | EE_Registry::instance()->SSN->checkout()->revisit |
| 456 | 456 | ); |
| 457 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
| 457 | + foreach ($registrations as $REG_ID => $registration) { |
|
| 458 | 458 | // has this registration lost it's space ? |
| 459 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
| 460 | - unset( $registrations[ $REG_ID ] ); |
|
| 459 | + if (isset($ejected_registrations[$REG_ID])) { |
|
| 460 | + unset($registrations[$REG_ID]); |
|
| 461 | 461 | continue; |
| 462 | 462 | } |
| 463 | 463 | } |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * @return array |
| 481 | 481 | * @throws \EE_Error |
| 482 | 482 | */ |
| 483 | - public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
|
| 483 | + public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) { |
|
| 484 | 484 | // registrations per event |
| 485 | 485 | $event_reg_count = array(); |
| 486 | 486 | // spaces left per event |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | $tickets_remaining = array(); |
| 490 | 490 | // registrations that have lost their space |
| 491 | 491 | $ejected_registrations = array(); |
| 492 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
| 492 | + foreach ($registrations as $REG_ID => $registration) { |
|
| 493 | 493 | if ( |
| 494 | 494 | $registration->status_ID() === EEM_Registration::status_id_approved |
| 495 | 495 | || apply_filters( |
@@ -519,13 +519,13 @@ discard block |
||
| 519 | 519 | $revisit |
| 520 | 520 | && ( |
| 521 | 521 | $tickets_remaining[$ticket->ID()] === 0 |
| 522 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
| 522 | + || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID] |
|
| 523 | 523 | ) |
| 524 | 524 | ) { |
| 525 | - $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
| 526 | - if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
|
| 525 | + $ejected_registrations[$REG_ID] = $registration->event(); |
|
| 526 | + if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
|
| 527 | 527 | /** @type EE_Registration_Processor $registration_processor */ |
| 528 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
| 528 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 529 | 529 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
| 530 | 530 | $registration_processor->manually_update_registration_status( |
| 531 | 531 | $registration, |
@@ -560,8 +560,8 @@ discard block |
||
| 560 | 560 | * @return void |
| 561 | 561 | */ |
| 562 | 562 | protected function _hide_reg_step_submit_button_if_revisit() { |
| 563 | - if ( $this->checkout->revisit ) { |
|
| 564 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
| 563 | + if ($this->checkout->revisit) { |
|
| 564 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | |
@@ -575,13 +575,13 @@ discard block |
||
| 575 | 575 | * @return \EE_Form_Section_Proper |
| 576 | 576 | * @throws \EE_Error |
| 577 | 577 | */ |
| 578 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
| 578 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
| 579 | 579 | // set some defaults |
| 580 | 580 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
| 581 | 581 | $sold_out_events = ''; |
| 582 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
| 582 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
| 583 | 583 | $sold_out_events .= EEH_HTML::li( |
| 584 | - EEH_HTML::span( ' ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
| 584 | + EEH_HTML::span(' '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
| 585 | 585 | ); |
| 586 | 586 | } |
| 587 | 587 | return new EE_Form_Section_Proper( |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | 'sold_out_events_msg' => apply_filters( |
| 600 | 600 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
| 601 | 601 | sprintf( |
| 602 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso' ), |
|
| 602 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso'), |
|
| 603 | 603 | '<strong>', |
| 604 | 604 | '</strong>', |
| 605 | 605 | '<br />' |
@@ -624,14 +624,14 @@ discard block |
||
| 624 | 624 | * @return \EE_Form_Section_Proper |
| 625 | 625 | * @throws \EE_Error |
| 626 | 626 | */ |
| 627 | - private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) { |
|
| 627 | + private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) { |
|
| 628 | 628 | // set some defaults |
| 629 | 629 | $this->checkout->selected_method_of_payment = 'invoice'; |
| 630 | 630 | $insufficient_space_events = ''; |
| 631 | - foreach ( $insufficient_spaces_events_array as $event ) { |
|
| 632 | - if ( $event instanceof EE_Event ) { |
|
| 631 | + foreach ($insufficient_spaces_events_array as $event) { |
|
| 632 | + if ($event instanceof EE_Event) { |
|
| 633 | 633 | $insufficient_space_events .= EEH_HTML::li( |
| 634 | - EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
| 634 | + EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
| 635 | 635 | ); |
| 636 | 636 | } |
| 637 | 637 | } |
@@ -675,17 +675,17 @@ discard block |
||
| 675 | 675 | * @return \EE_Form_Section_Proper |
| 676 | 676 | * @throws \EE_Error |
| 677 | 677 | */ |
| 678 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
| 678 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
| 679 | 679 | $events_requiring_pre_approval = ''; |
| 680 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
| 681 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
| 682 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
| 680 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
| 681 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
| 682 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
| 683 | 683 | EEH_HTML::span( |
| 684 | 684 | '', |
| 685 | 685 | '', |
| 686 | 686 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
| 687 | 687 | ) |
| 688 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
| 688 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
| 689 | 689 | ); |
| 690 | 690 | } |
| 691 | 691 | } |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | 'template_args' => apply_filters( |
| 701 | 701 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
| 702 | 702 | array( |
| 703 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
| 703 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
| 704 | 704 | 'events_requiring_pre_approval_msg' => apply_filters( |
| 705 | 705 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
| 706 | 706 | __( |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | * @return \EE_Form_Section_Proper |
| 726 | 726 | * @throws \EE_Error |
| 727 | 727 | */ |
| 728 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
| 728 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
| 729 | 729 | // set some defaults |
| 730 | 730 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
| 731 | 731 | // generate no_payment_required form |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | 'ticket_count' => array(), |
| 746 | 746 | 'registrations_for_free_events' => $registrations_for_free_events, |
| 747 | 747 | 'no_payment_required_msg' => EEH_HTML::p( |
| 748 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
| 748 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
| 749 | 749 | ) |
| 750 | 750 | ) |
| 751 | 751 | ), |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | * @return \EE_Form_Section_Proper |
| 765 | 765 | * @throws \EE_Error |
| 766 | 766 | */ |
| 767 | - private function _display_payment_options( $transaction_details = '' ) { |
|
| 767 | + private function _display_payment_options($transaction_details = '') { |
|
| 768 | 768 | // has method_of_payment been set by no-js user? |
| 769 | 769 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
| 770 | 770 | // build payment options form |
@@ -776,14 +776,14 @@ discard block |
||
| 776 | 776 | 'before_payment_options' => apply_filters( |
| 777 | 777 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
| 778 | 778 | new EE_Form_Section_Proper( |
| 779 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
| 779 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
| 780 | 780 | ) |
| 781 | 781 | ), |
| 782 | 782 | 'payment_options' => $this->_setup_payment_options(), |
| 783 | 783 | 'after_payment_options' => apply_filters( |
| 784 | 784 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
| 785 | 785 | new EE_Form_Section_Proper( |
| 786 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
| 786 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
| 787 | 787 | ) |
| 788 | 788 | ), |
| 789 | 789 | ), |
@@ -814,10 +814,10 @@ discard block |
||
| 814 | 814 | * @return \EE_Form_Section_Proper |
| 815 | 815 | * @throws \EE_Error |
| 816 | 816 | */ |
| 817 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
| 817 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
| 818 | 818 | return new EE_Form_Section_Proper( |
| 819 | 819 | array( |
| 820 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
| 820 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
| 821 | 821 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
| 822 | 822 | 'subsections' => array( |
| 823 | 823 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -849,16 +849,16 @@ discard block |
||
| 849 | 849 | * @access protected |
| 850 | 850 | * @param array $registrations |
| 851 | 851 | */ |
| 852 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
| 852 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
| 853 | 853 | $payments = array(); |
| 854 | - foreach ( $registrations as $registration ) { |
|
| 855 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
| 854 | + foreach ($registrations as $registration) { |
|
| 855 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
| 856 | 856 | $payments += $registration->registration_payments(); |
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | - if ( ! empty( $payments ) ) { |
|
| 860 | - foreach ( $payments as $payment ) { |
|
| 861 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
| 859 | + if ( ! empty($payments)) { |
|
| 860 | + foreach ($payments as $payment) { |
|
| 861 | + if ($payment instanceof EE_Registration_Payment) { |
|
| 862 | 862 | $this->checkout->amount_owing -= $payment->amount(); |
| 863 | 863 | } |
| 864 | 864 | } |
@@ -874,11 +874,11 @@ discard block |
||
| 874 | 874 | * @param bool $force_reset |
| 875 | 875 | * @return void |
| 876 | 876 | */ |
| 877 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
| 877 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
| 878 | 878 | $reset_payment_method = $force_reset |
| 879 | 879 | ? true |
| 880 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
| 881 | - if ( $reset_payment_method ) { |
|
| 880 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
| 881 | + if ($reset_payment_method) { |
|
| 882 | 882 | $this->checkout->selected_method_of_payment = null; |
| 883 | 883 | $this->checkout->payment_method = null; |
| 884 | 884 | $this->checkout->billing_form = null; |
@@ -897,12 +897,12 @@ discard block |
||
| 897 | 897 | * @param string $selected_method_of_payment |
| 898 | 898 | * @return void |
| 899 | 899 | */ |
| 900 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
| 901 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
| 900 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
| 901 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
| 902 | 902 | ? $selected_method_of_payment |
| 903 | 903 | : $this->checkout->selected_method_of_payment; |
| 904 | 904 | EE_Registry::instance()->SSN->set_session_data( |
| 905 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
| 905 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
| 906 | 906 | ); |
| 907 | 907 | } |
| 908 | 908 | |
@@ -918,19 +918,19 @@ discard block |
||
| 918 | 918 | // load payment method classes |
| 919 | 919 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
| 920 | 920 | // switch up header depending on number of available payment methods |
| 921 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
| 921 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
| 922 | 922 | ? apply_filters( |
| 923 | 923 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
| 924 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
| 924 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
| 925 | 925 | ) |
| 926 | 926 | : apply_filters( |
| 927 | 927 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
| 928 | - __( 'Method of Payment', 'event_espresso' ) |
|
| 928 | + __('Method of Payment', 'event_espresso') |
|
| 929 | 929 | ); |
| 930 | 930 | $available_payment_methods = array( |
| 931 | 931 | // display the "Payment Method" header |
| 932 | 932 | 'payment_method_header' => new EE_Form_Section_HTML( |
| 933 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
| 933 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
| 934 | 934 | ) |
| 935 | 935 | ); |
| 936 | 936 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -939,32 +939,32 @@ discard block |
||
| 939 | 939 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
| 940 | 940 | $payment_methods_billing_info = array( |
| 941 | 941 | new EE_Form_Section_HTML( |
| 942 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
| 942 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
| 943 | 943 | ) |
| 944 | 944 | ); |
| 945 | 945 | // loop through payment methods |
| 946 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
| 947 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
| 946 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
| 947 | + if ($payment_method instanceof EE_Payment_Method) { |
|
| 948 | 948 | $payment_method_button = EEH_HTML::img( |
| 949 | 949 | $payment_method->button_url(), |
| 950 | 950 | $payment_method->name(), |
| 951 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
| 951 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
| 952 | 952 | 'spco-payment-method-btn-img' |
| 953 | 953 | ); |
| 954 | 954 | // check if any payment methods are set as default |
| 955 | 955 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
| 956 | 956 | if ( |
| 957 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
| 958 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
| 957 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
| 958 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
| 959 | 959 | ) { |
| 960 | 960 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
| 961 | 961 | $this->_save_selected_method_of_payment(); |
| 962 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
| 962 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
| 963 | 963 | } else { |
| 964 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
| 964 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
| 965 | 965 | } |
| 966 | - $payment_methods_billing_info[ $payment_method->slug() |
|
| 967 | - . '-info' ] = $this->_payment_method_billing_info( |
|
| 966 | + $payment_methods_billing_info[$payment_method->slug() |
|
| 967 | + . '-info'] = $this->_payment_method_billing_info( |
|
| 968 | 968 | $payment_method |
| 969 | 969 | ); |
| 970 | 970 | } |
@@ -994,12 +994,12 @@ discard block |
||
| 994 | 994 | * @return EE_Payment_Method[] |
| 995 | 995 | */ |
| 996 | 996 | protected function _get_available_payment_methods() { |
| 997 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
| 997 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
| 998 | 998 | return $this->checkout->available_payment_methods; |
| 999 | 999 | } |
| 1000 | 1000 | $available_payment_methods = array(); |
| 1001 | 1001 | // load EEM_Payment_Method |
| 1002 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
| 1002 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 1003 | 1003 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
| 1004 | 1004 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
| 1005 | 1005 | // get all active payment methods |
@@ -1007,9 +1007,9 @@ discard block |
||
| 1007 | 1007 | $this->checkout->transaction, |
| 1008 | 1008 | EEM_Payment_Method::scope_cart |
| 1009 | 1009 | ); |
| 1010 | - foreach ( $payment_methods as $payment_method ) { |
|
| 1011 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
| 1012 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
| 1010 | + foreach ($payment_methods as $payment_method) { |
|
| 1011 | + if ($payment_method instanceof EE_Payment_Method) { |
|
| 1012 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
| 1013 | 1013 | } |
| 1014 | 1014 | } |
| 1015 | 1015 | return $available_payment_methods; |
@@ -1024,14 +1024,14 @@ discard block |
||
| 1024 | 1024 | * @param array $available_payment_method_options |
| 1025 | 1025 | * @return \EE_Form_Section_Proper |
| 1026 | 1026 | */ |
| 1027 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
| 1027 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
| 1028 | 1028 | // generate inputs |
| 1029 | 1029 | return new EE_Form_Section_Proper( |
| 1030 | 1030 | array( |
| 1031 | 1031 | 'html_id' => 'ee-available-payment-method-inputs', |
| 1032 | 1032 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
| 1033 | 1033 | 'subsections' => array( |
| 1034 | - '' => new EE_Radio_Button_Input ( |
|
| 1034 | + '' => new EE_Radio_Button_Input( |
|
| 1035 | 1035 | $available_payment_method_options, |
| 1036 | 1036 | array( |
| 1037 | 1037 | 'html_name' => 'selected_method_of_payment', |
@@ -1056,28 +1056,28 @@ discard block |
||
| 1056 | 1056 | * @return \EE_Form_Section_Proper |
| 1057 | 1057 | * @throws \EE_Error |
| 1058 | 1058 | */ |
| 1059 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
| 1059 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
| 1060 | 1060 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
| 1061 | 1061 | ? true |
| 1062 | 1062 | : false; |
| 1063 | 1063 | // generate the billing form for payment method |
| 1064 | 1064 | $billing_form = $currently_selected |
| 1065 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
| 1065 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
| 1066 | 1066 | : new EE_Form_Section_HTML(); |
| 1067 | 1067 | $this->checkout->billing_form = $currently_selected |
| 1068 | 1068 | ? $billing_form |
| 1069 | 1069 | : $this->checkout->billing_form; |
| 1070 | 1070 | // it's all in the details |
| 1071 | 1071 | $info_html = EEH_HTML::h3( |
| 1072 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
| 1072 | + __('Important information regarding your payment', 'event_espresso'), |
|
| 1073 | 1073 | '', |
| 1074 | 1074 | 'spco-payment-method-hdr' |
| 1075 | 1075 | ); |
| 1076 | 1076 | // add some info regarding the step, either from what's saved in the admin, |
| 1077 | 1077 | // or a default string depending on whether the PM has a billing form or not |
| 1078 | - if ( $payment_method->description() ) { |
|
| 1078 | + if ($payment_method->description()) { |
|
| 1079 | 1079 | $payment_method_info = $payment_method->description(); |
| 1080 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
| 1080 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
| 1081 | 1081 | $payment_method_info = sprintf( |
| 1082 | 1082 | __( |
| 1083 | 1083 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | ); |
| 1088 | 1088 | } else { |
| 1089 | 1089 | $payment_method_info = sprintf( |
| 1090 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
| 1090 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
| 1091 | 1091 | $this->submit_button_text() |
| 1092 | 1092 | ); |
| 1093 | 1093 | } |
@@ -1101,13 +1101,13 @@ discard block |
||
| 1101 | 1101 | ); |
| 1102 | 1102 | return new EE_Form_Section_Proper( |
| 1103 | 1103 | array( |
| 1104 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
| 1104 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
| 1105 | 1105 | 'html_class' => 'spco-payment-method-info-dv', |
| 1106 | 1106 | // only display the selected or default PM |
| 1107 | 1107 | 'html_style' => $currently_selected ? '' : 'display:none;', |
| 1108 | 1108 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
| 1109 | 1109 | 'subsections' => array( |
| 1110 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
| 1110 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
| 1111 | 1111 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
| 1112 | 1112 | ) |
| 1113 | 1113 | ) |
@@ -1125,15 +1125,15 @@ discard block |
||
| 1125 | 1125 | */ |
| 1126 | 1126 | public function get_billing_form_html_for_payment_method() { |
| 1127 | 1127 | // how have they chosen to pay? |
| 1128 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
| 1128 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 1129 | 1129 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
| 1130 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
| 1130 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1131 | 1131 | return false; |
| 1132 | 1132 | } |
| 1133 | - if ( apply_filters( |
|
| 1133 | + if (apply_filters( |
|
| 1134 | 1134 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
| 1135 | 1135 | false |
| 1136 | - ) ) { |
|
| 1136 | + )) { |
|
| 1137 | 1137 | EE_Error::add_success( |
| 1138 | 1138 | apply_filters( |
| 1139 | 1139 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | ); |
| 1149 | 1149 | } |
| 1150 | 1150 | // now generate billing form for selected method of payment |
| 1151 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
| 1151 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
| 1152 | 1152 | // fill form with attendee info if applicable |
| 1153 | 1153 | if ( |
| 1154 | 1154 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -1170,10 +1170,10 @@ discard block |
||
| 1170 | 1170 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
| 1171 | 1171 | ? $payment_method_billing_form->get_html() |
| 1172 | 1172 | : ''; |
| 1173 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
| 1173 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
| 1174 | 1174 | // localize validation rules for main form |
| 1175 | 1175 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
| 1176 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
| 1176 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 1177 | 1177 | return true; |
| 1178 | 1178 | } |
| 1179 | 1179 | |
@@ -1187,18 +1187,18 @@ discard block |
||
| 1187 | 1187 | * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML |
| 1188 | 1188 | * @throws \EE_Error |
| 1189 | 1189 | */ |
| 1190 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
| 1190 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
| 1191 | 1191 | $billing_form = $payment_method->type_obj()->billing_form( |
| 1192 | 1192 | $this->checkout->transaction, |
| 1193 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
| 1193 | + array('amount_owing' => $this->checkout->amount_owing) |
|
| 1194 | 1194 | ); |
| 1195 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
| 1195 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
| 1196 | 1196 | if ( |
| 1197 | 1197 | apply_filters( |
| 1198 | 1198 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
| 1199 | 1199 | false |
| 1200 | 1200 | ) |
| 1201 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
| 1201 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
| 1202 | 1202 | ) { |
| 1203 | 1203 | EE_Error::add_success( |
| 1204 | 1204 | apply_filters( |
@@ -1240,15 +1240,15 @@ discard block |
||
| 1240 | 1240 | $request_param = 'selected_method_of_payment' |
| 1241 | 1241 | ) { |
| 1242 | 1242 | // is selected_method_of_payment set in the request ? |
| 1243 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
| 1244 | - if ( $selected_method_of_payment ) { |
|
| 1243 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
| 1244 | + if ($selected_method_of_payment) { |
|
| 1245 | 1245 | // sanitize it |
| 1246 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
| 1247 | - ? array_shift( $selected_method_of_payment ) |
|
| 1246 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
| 1247 | + ? array_shift($selected_method_of_payment) |
|
| 1248 | 1248 | : $selected_method_of_payment; |
| 1249 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
| 1249 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
| 1250 | 1250 | // store it in the session so that it's available for all subsequent requests including AJAX |
| 1251 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
| 1251 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
| 1252 | 1252 | } else { |
| 1253 | 1253 | // or is is set in the session ? |
| 1254 | 1254 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1256,7 +1256,7 @@ discard block |
||
| 1256 | 1256 | ); |
| 1257 | 1257 | } |
| 1258 | 1258 | // do ya really really gotta have it? |
| 1259 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
| 1259 | + if (empty($selected_method_of_payment) && $required) { |
|
| 1260 | 1260 | EE_Error::add_error( |
| 1261 | 1261 | sprintf( |
| 1262 | 1262 | __( |
@@ -1265,7 +1265,7 @@ discard block |
||
| 1265 | 1265 | ), |
| 1266 | 1266 | '<br/>', |
| 1267 | 1267 | '<br/>', |
| 1268 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1268 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1269 | 1269 | ), |
| 1270 | 1270 | __FILE__, |
| 1271 | 1271 | __FUNCTION__, |
@@ -1292,13 +1292,13 @@ discard block |
||
| 1292 | 1292 | * @throws \EE_Error |
| 1293 | 1293 | */ |
| 1294 | 1294 | public function switch_payment_method() { |
| 1295 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
| 1295 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
| 1296 | 1296 | return false; |
| 1297 | 1297 | } |
| 1298 | - if ( apply_filters( |
|
| 1298 | + if (apply_filters( |
|
| 1299 | 1299 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
| 1300 | 1300 | false |
| 1301 | - ) ) { |
|
| 1301 | + )) { |
|
| 1302 | 1302 | EE_Error::add_success( |
| 1303 | 1303 | apply_filters( |
| 1304 | 1304 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | ); |
| 1314 | 1314 | } |
| 1315 | 1315 | // generate billing form for selected method of payment if it hasn't been done already |
| 1316 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
| 1316 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1317 | 1317 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
| 1318 | 1318 | $this->checkout->payment_method |
| 1319 | 1319 | ); |
@@ -1335,7 +1335,7 @@ discard block |
||
| 1335 | 1335 | ); |
| 1336 | 1336 | } |
| 1337 | 1337 | // and debug content |
| 1338 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
| 1338 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
| 1339 | 1339 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
| 1340 | 1340 | ) { |
| 1341 | 1341 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1343,15 +1343,15 @@ discard block |
||
| 1343 | 1343 | ); |
| 1344 | 1344 | } |
| 1345 | 1345 | // get html and validation rules for form |
| 1346 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
| 1346 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
| 1347 | 1347 | $this->checkout->json_response->set_return_data( |
| 1348 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
| 1348 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
| 1349 | 1349 | ); |
| 1350 | 1350 | // localize validation rules for main form |
| 1351 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
| 1352 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
| 1351 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
| 1352 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 1353 | 1353 | } else { |
| 1354 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
| 1354 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
| 1355 | 1355 | } |
| 1356 | 1356 | //prevents advancement to next step |
| 1357 | 1357 | $this->checkout->continue_reg = false; |
@@ -1368,18 +1368,18 @@ discard block |
||
| 1368 | 1368 | */ |
| 1369 | 1369 | protected function _verify_payment_method_is_set() { |
| 1370 | 1370 | // generate billing form for selected method of payment if it hasn't been done already |
| 1371 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
| 1371 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
| 1372 | 1372 | // how have they chosen to pay? |
| 1373 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
| 1373 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 1374 | 1374 | } else { |
| 1375 | 1375 | // choose your own adventure based on method_of_payment |
| 1376 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
| 1376 | + switch ($this->checkout->selected_method_of_payment) { |
|
| 1377 | 1377 | case 'events_sold_out' : |
| 1378 | 1378 | EE_Error::add_attention( |
| 1379 | 1379 | apply_filters( |
| 1380 | 1380 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg', |
| 1381 | - __( 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
| 1382 | - 'event_espresso' ) |
|
| 1381 | + __('It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
| 1382 | + 'event_espresso') |
|
| 1383 | 1383 | ), |
| 1384 | 1384 | __FILE__, __FUNCTION__, __LINE__ |
| 1385 | 1385 | ); |
@@ -1389,7 +1389,7 @@ discard block |
||
| 1389 | 1389 | EE_Error::add_attention( |
| 1390 | 1390 | apply_filters( |
| 1391 | 1391 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg', |
| 1392 | - __( 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
| 1392 | + __('It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
| 1393 | 1393 | ), |
| 1394 | 1394 | __FILE__, __FUNCTION__, __LINE__ |
| 1395 | 1395 | ); |
@@ -1399,7 +1399,7 @@ discard block |
||
| 1399 | 1399 | EE_Error::add_attention( |
| 1400 | 1400 | apply_filters( |
| 1401 | 1401 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg', |
| 1402 | - __( 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
| 1402 | + __('It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
| 1403 | 1403 | ), |
| 1404 | 1404 | __FILE__, __FUNCTION__, __LINE__ |
| 1405 | 1405 | ); |
@@ -1409,7 +1409,7 @@ discard block |
||
| 1409 | 1409 | } |
| 1410 | 1410 | } |
| 1411 | 1411 | // verify payment method |
| 1412 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
| 1412 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1413 | 1413 | // get payment method for selected method of payment |
| 1414 | 1414 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
| 1415 | 1415 | } |
@@ -1428,25 +1428,25 @@ discard block |
||
| 1428 | 1428 | * @throws \EE_Error |
| 1429 | 1429 | */ |
| 1430 | 1430 | public function save_payer_details_via_ajax() { |
| 1431 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
| 1431 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
| 1432 | 1432 | return; |
| 1433 | 1433 | } |
| 1434 | 1434 | // generate billing form for selected method of payment if it hasn't been done already |
| 1435 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
| 1435 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1436 | 1436 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
| 1437 | 1437 | $this->checkout->payment_method |
| 1438 | 1438 | ); |
| 1439 | 1439 | } |
| 1440 | 1440 | // generate primary attendee from payer info if applicable |
| 1441 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
| 1441 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
| 1442 | 1442 | $attendee = $this->_create_attendee_from_request_data(); |
| 1443 | - if ( $attendee instanceof EE_Attendee ) { |
|
| 1444 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
| 1445 | - if ( $registration->is_primary_registrant() ) { |
|
| 1443 | + if ($attendee instanceof EE_Attendee) { |
|
| 1444 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
| 1445 | + if ($registration->is_primary_registrant()) { |
|
| 1446 | 1446 | $this->checkout->primary_attendee_obj = $attendee; |
| 1447 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
| 1448 | - $registration->set_attendee_id( $attendee->ID() ); |
|
| 1449 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
| 1447 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
| 1448 | + $registration->set_attendee_id($attendee->ID()); |
|
| 1449 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
| 1450 | 1450 | } |
| 1451 | 1451 | } |
| 1452 | 1452 | } |
@@ -1464,50 +1464,50 @@ discard block |
||
| 1464 | 1464 | */ |
| 1465 | 1465 | protected function _create_attendee_from_request_data() { |
| 1466 | 1466 | // get State ID |
| 1467 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
| 1468 | - if ( ! empty( $STA_ID ) ) { |
|
| 1467 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
| 1468 | + if ( ! empty($STA_ID)) { |
|
| 1469 | 1469 | // can we get state object from name ? |
| 1470 | - EE_Registry::instance()->load_model( 'State' ); |
|
| 1471 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
| 1472 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
| 1470 | + EE_Registry::instance()->load_model('State'); |
|
| 1471 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
| 1472 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
| 1473 | 1473 | } |
| 1474 | 1474 | // get Country ISO |
| 1475 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
| 1476 | - if ( ! empty( $CNT_ISO ) ) { |
|
| 1475 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
| 1476 | + if ( ! empty($CNT_ISO)) { |
|
| 1477 | 1477 | // can we get country object from name ? |
| 1478 | - EE_Registry::instance()->load_model( 'Country' ); |
|
| 1478 | + EE_Registry::instance()->load_model('Country'); |
|
| 1479 | 1479 | $country = EEM_Country::instance()->get_col( |
| 1480 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
| 1480 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
| 1481 | 1481 | 'CNT_ISO' |
| 1482 | 1482 | ); |
| 1483 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
| 1483 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
| 1484 | 1484 | } |
| 1485 | 1485 | // grab attendee data |
| 1486 | 1486 | $attendee_data = array( |
| 1487 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
| 1488 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
| 1489 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
| 1490 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
| 1491 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
| 1492 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
| 1487 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
| 1488 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
| 1489 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
| 1490 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
| 1491 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
| 1492 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
| 1493 | 1493 | 'STA_ID' => $STA_ID, |
| 1494 | 1494 | 'CNT_ISO' => $CNT_ISO, |
| 1495 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
| 1496 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
| 1495 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
| 1496 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
| 1497 | 1497 | ); |
| 1498 | 1498 | // validate the email address since it is the most important piece of info |
| 1499 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
| 1499 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
| 1500 | 1500 | EE_Error::add_error( |
| 1501 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
| 1501 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
| 1502 | 1502 | __FILE__, |
| 1503 | 1503 | __FUNCTION__, |
| 1504 | 1504 | __LINE__ |
| 1505 | 1505 | ); |
| 1506 | 1506 | } |
| 1507 | 1507 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
| 1508 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
| 1509 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
| 1510 | - && ! empty( $attendee_data['ATT_email'] ) |
|
| 1508 | + if ( ! empty($attendee_data['ATT_fname']) |
|
| 1509 | + && ! empty($attendee_data['ATT_lname']) |
|
| 1510 | + && ! empty($attendee_data['ATT_email']) |
|
| 1511 | 1511 | ) { |
| 1512 | 1512 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
| 1513 | 1513 | array( |
@@ -1516,19 +1516,19 @@ discard block |
||
| 1516 | 1516 | 'ATT_email' => $attendee_data['ATT_email'] |
| 1517 | 1517 | ) |
| 1518 | 1518 | ); |
| 1519 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
| 1519 | + if ($existing_attendee instanceof EE_Attendee) { |
|
| 1520 | 1520 | return $existing_attendee; |
| 1521 | 1521 | } |
| 1522 | 1522 | } |
| 1523 | 1523 | // no existing attendee? kk let's create a new one |
| 1524 | 1524 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
| 1525 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
| 1525 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
| 1526 | 1526 | ? $attendee_data['ATT_fname'] |
| 1527 | 1527 | : $attendee_data['ATT_email']; |
| 1528 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
| 1528 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
| 1529 | 1529 | ? $attendee_data['ATT_lname'] |
| 1530 | 1530 | : $attendee_data['ATT_email']; |
| 1531 | - return EE_Attendee::new_instance( $attendee_data ); |
|
| 1531 | + return EE_Attendee::new_instance($attendee_data); |
|
| 1532 | 1532 | } |
| 1533 | 1533 | |
| 1534 | 1534 | |
@@ -1546,26 +1546,26 @@ discard block |
||
| 1546 | 1546 | // how have they chosen to pay? |
| 1547 | 1547 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
| 1548 | 1548 | ? 'no_payment_required' |
| 1549 | - : $this->_get_selected_method_of_payment( true ); |
|
| 1549 | + : $this->_get_selected_method_of_payment(true); |
|
| 1550 | 1550 | // choose your own adventure based on method_of_payment |
| 1551 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
| 1551 | + switch ($this->checkout->selected_method_of_payment) { |
|
| 1552 | 1552 | |
| 1553 | 1553 | case 'events_sold_out' : |
| 1554 | 1554 | $this->checkout->redirect = true; |
| 1555 | 1555 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
| 1556 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
| 1556 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
| 1557 | 1557 | // mark this reg step as completed |
| 1558 | 1558 | $this->set_completed(); |
| 1559 | 1559 | return false; |
| 1560 | 1560 | break; |
| 1561 | 1561 | |
| 1562 | 1562 | case 'payments_closed' : |
| 1563 | - if ( apply_filters( |
|
| 1563 | + if (apply_filters( |
|
| 1564 | 1564 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
| 1565 | 1565 | false |
| 1566 | - ) ) { |
|
| 1566 | + )) { |
|
| 1567 | 1567 | EE_Error::add_success( |
| 1568 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
| 1568 | + __('no payment required at this time.', 'event_espresso'), |
|
| 1569 | 1569 | __FILE__, |
| 1570 | 1570 | __FUNCTION__, |
| 1571 | 1571 | __LINE__ |
@@ -1577,12 +1577,12 @@ discard block |
||
| 1577 | 1577 | break; |
| 1578 | 1578 | |
| 1579 | 1579 | case 'no_payment_required' : |
| 1580 | - if ( apply_filters( |
|
| 1580 | + if (apply_filters( |
|
| 1581 | 1581 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
| 1582 | 1582 | false |
| 1583 | - ) ) { |
|
| 1583 | + )) { |
|
| 1584 | 1584 | EE_Error::add_success( |
| 1585 | - __( 'no payment required.', 'event_espresso' ), |
|
| 1585 | + __('no payment required.', 'event_espresso'), |
|
| 1586 | 1586 | __FILE__, |
| 1587 | 1587 | __FUNCTION__, |
| 1588 | 1588 | __LINE__ |
@@ -1602,15 +1602,15 @@ discard block |
||
| 1602 | 1602 | EE_Registry::instance()->SSN->checkout()->revisit |
| 1603 | 1603 | ); |
| 1604 | 1604 | // calculate difference between the two arrays |
| 1605 | - $registrations = array_diff( $registrations, $ejected_registrations ); |
|
| 1606 | - if ( empty( $registrations ) ) { |
|
| 1605 | + $registrations = array_diff($registrations, $ejected_registrations); |
|
| 1606 | + if (empty($registrations)) { |
|
| 1607 | 1607 | $this->_redirect_because_event_sold_out(); |
| 1608 | 1608 | return false; |
| 1609 | 1609 | } |
| 1610 | 1610 | $payment_successful = $this->_process_payment(); |
| 1611 | - if ( $payment_successful ) { |
|
| 1611 | + if ($payment_successful) { |
|
| 1612 | 1612 | $this->checkout->continue_reg = true; |
| 1613 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
| 1613 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
| 1614 | 1614 | } else { |
| 1615 | 1615 | $this->checkout->continue_reg = false; |
| 1616 | 1616 | } |
@@ -1631,10 +1631,10 @@ discard block |
||
| 1631 | 1631 | $this->checkout->continue_reg = false; |
| 1632 | 1632 | // set redirect URL |
| 1633 | 1633 | $this->checkout->redirect_url = add_query_arg( |
| 1634 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
| 1634 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
| 1635 | 1635 | $this->checkout->current_step->reg_step_url() |
| 1636 | 1636 | ); |
| 1637 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
| 1637 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
| 1638 | 1638 | } |
| 1639 | 1639 | |
| 1640 | 1640 | |
@@ -1647,8 +1647,8 @@ discard block |
||
| 1647 | 1647 | * @return void |
| 1648 | 1648 | * @throws \EE_Error |
| 1649 | 1649 | */ |
| 1650 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
| 1651 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
| 1650 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
| 1651 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
| 1652 | 1652 | case EE_PMT_Base::offsite : |
| 1653 | 1653 | break; |
| 1654 | 1654 | case EE_PMT_Base::onsite : |
@@ -1671,7 +1671,7 @@ discard block |
||
| 1671 | 1671 | public function update_reg_step() { |
| 1672 | 1672 | $success = true; |
| 1673 | 1673 | // if payment required |
| 1674 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
| 1674 | + if ($this->checkout->transaction->total() > 0) { |
|
| 1675 | 1675 | do_action( |
| 1676 | 1676 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
| 1677 | 1677 | $this->checkout->transaction |
@@ -1679,13 +1679,13 @@ discard block |
||
| 1679 | 1679 | // attempt payment via payment method |
| 1680 | 1680 | $success = $this->process_reg_step(); |
| 1681 | 1681 | } |
| 1682 | - if ( $success && ! $this->checkout->redirect ) { |
|
| 1682 | + if ($success && ! $this->checkout->redirect) { |
|
| 1683 | 1683 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
| 1684 | 1684 | $this->checkout->transaction->ID() |
| 1685 | 1685 | ); |
| 1686 | 1686 | // set return URL |
| 1687 | 1687 | $this->checkout->redirect_url = add_query_arg( |
| 1688 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
| 1688 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
| 1689 | 1689 | $this->checkout->thank_you_page_url |
| 1690 | 1690 | ); |
| 1691 | 1691 | } |
@@ -1703,36 +1703,36 @@ discard block |
||
| 1703 | 1703 | */ |
| 1704 | 1704 | private function _process_payment() { |
| 1705 | 1705 | // basically confirm that the event hasn't sold out since they hit the page |
| 1706 | - if ( ! $this->_last_second_ticket_verifications() ) { |
|
| 1706 | + if ( ! $this->_last_second_ticket_verifications()) { |
|
| 1707 | 1707 | return false; |
| 1708 | 1708 | } |
| 1709 | 1709 | // ya gotta make a choice man |
| 1710 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
| 1710 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
| 1711 | 1711 | $this->checkout->json_response->set_plz_select_method_of_payment( |
| 1712 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
| 1712 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
| 1713 | 1713 | ); |
| 1714 | 1714 | return false; |
| 1715 | 1715 | } |
| 1716 | 1716 | // get EE_Payment_Method object |
| 1717 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
| 1717 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 1718 | 1718 | return false; |
| 1719 | 1719 | } |
| 1720 | 1720 | // setup billing form |
| 1721 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
| 1721 | + if ($this->checkout->payment_method->is_on_site()) { |
|
| 1722 | 1722 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
| 1723 | 1723 | $this->checkout->payment_method |
| 1724 | 1724 | ); |
| 1725 | 1725 | // bad billing form ? |
| 1726 | - if ( ! $this->_billing_form_is_valid() ) { |
|
| 1726 | + if ( ! $this->_billing_form_is_valid()) { |
|
| 1727 | 1727 | return false; |
| 1728 | 1728 | } |
| 1729 | 1729 | } |
| 1730 | 1730 | // ensure primary registrant has been fully processed |
| 1731 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
| 1731 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
| 1732 | 1732 | return false; |
| 1733 | 1733 | } |
| 1734 | 1734 | // if session is close to expiring (under 10 minutes by default) |
| 1735 | - if ( ( time() - EE_Registry::instance()->SSN->expiration() ) < EE_Registry::instance()->SSN->extension() ) { |
|
| 1735 | + if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) { |
|
| 1736 | 1736 | // add some time to session expiration so that payment can be completed |
| 1737 | 1737 | EE_Registry::instance()->SSN->extend_expiration(); |
| 1738 | 1738 | } |
@@ -1741,12 +1741,12 @@ discard block |
||
| 1741 | 1741 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
| 1742 | 1742 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
| 1743 | 1743 | // attempt payment |
| 1744 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
| 1744 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
| 1745 | 1745 | // process results |
| 1746 | - $payment = $this->_validate_payment( $payment ); |
|
| 1747 | - $payment = $this->_post_payment_processing( $payment ); |
|
| 1746 | + $payment = $this->_validate_payment($payment); |
|
| 1747 | + $payment = $this->_post_payment_processing($payment); |
|
| 1748 | 1748 | // verify payment |
| 1749 | - if ( $payment instanceof EE_Payment ) { |
|
| 1749 | + if ($payment instanceof EE_Payment) { |
|
| 1750 | 1750 | // store that for later |
| 1751 | 1751 | $this->checkout->payment = $payment; |
| 1752 | 1752 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
@@ -1760,7 +1760,7 @@ discard block |
||
| 1760 | 1760 | } else { |
| 1761 | 1761 | return false; |
| 1762 | 1762 | } |
| 1763 | - } else if ( $payment === true ) { |
|
| 1763 | + } else if ($payment === true) { |
|
| 1764 | 1764 | // please note that offline payment methods will NOT make a payment, |
| 1765 | 1765 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
| 1766 | 1766 | $this->checkout->payment = $payment; |
@@ -1780,22 +1780,22 @@ discard block |
||
| 1780 | 1780 | */ |
| 1781 | 1781 | protected function _last_second_ticket_verifications() { |
| 1782 | 1782 | // don't bother re-validating if not a return visit |
| 1783 | - if ( ! $this->checkout->revisit ) { |
|
| 1783 | + if ( ! $this->checkout->revisit) { |
|
| 1784 | 1784 | return true; |
| 1785 | 1785 | } |
| 1786 | 1786 | $registrations = $this->checkout->transaction->registrations(); |
| 1787 | - if ( empty( $registrations ) ) { |
|
| 1787 | + if (empty($registrations)) { |
|
| 1788 | 1788 | return false; |
| 1789 | 1789 | } |
| 1790 | - foreach ( $registrations as $registration ) { |
|
| 1791 | - if ( $registration instanceof EE_Registration ) { |
|
| 1790 | + foreach ($registrations as $registration) { |
|
| 1791 | + if ($registration instanceof EE_Registration) { |
|
| 1792 | 1792 | $event = $registration->event_obj(); |
| 1793 | - if ( $event instanceof EE_Event && $event->is_sold_out( true ) ) { |
|
| 1793 | + if ($event instanceof EE_Event && $event->is_sold_out(true)) { |
|
| 1794 | 1794 | EE_Error::add_error( |
| 1795 | 1795 | apply_filters( |
| 1796 | 1796 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg', |
| 1797 | 1797 | sprintf( |
| 1798 | - __( 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ), |
|
| 1798 | + __('It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'), |
|
| 1799 | 1799 | $event->name() |
| 1800 | 1800 | ) |
| 1801 | 1801 | ), |
@@ -1825,7 +1825,7 @@ discard block |
||
| 1825 | 1825 | ); |
| 1826 | 1826 | $html = $payment_method_billing_info->get_html(); |
| 1827 | 1827 | $html .= $this->checkout->redirect_form; |
| 1828 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
| 1828 | + EE_Registry::instance()->REQ->add_output($html); |
|
| 1829 | 1829 | return true; |
| 1830 | 1830 | } |
| 1831 | 1831 | |
@@ -1839,28 +1839,28 @@ discard block |
||
| 1839 | 1839 | * @throws \EE_Error |
| 1840 | 1840 | */ |
| 1841 | 1841 | private function _billing_form_is_valid() { |
| 1842 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
| 1842 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1843 | 1843 | return true; |
| 1844 | 1844 | } |
| 1845 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
| 1846 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
| 1845 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
| 1846 | + if ($this->checkout->billing_form->was_submitted()) { |
|
| 1847 | 1847 | $this->checkout->billing_form->receive_form_submission(); |
| 1848 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
| 1848 | + if ($this->checkout->billing_form->is_valid()) { |
|
| 1849 | 1849 | return true; |
| 1850 | 1850 | } |
| 1851 | 1851 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
| 1852 | 1852 | $error_strings = array(); |
| 1853 | - foreach ( $validation_errors as $validation_error ) { |
|
| 1854 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
| 1853 | + foreach ($validation_errors as $validation_error) { |
|
| 1854 | + if ($validation_error instanceof EE_Validation_Error) { |
|
| 1855 | 1855 | $form_section = $validation_error->get_form_section(); |
| 1856 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
| 1856 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
| 1857 | 1857 | $label = $form_section->html_label_text(); |
| 1858 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
| 1858 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
| 1859 | 1859 | $label = $form_section->name(); |
| 1860 | 1860 | } else { |
| 1861 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
| 1861 | + $label = __('Validation Error', 'event_espresso'); |
|
| 1862 | 1862 | } |
| 1863 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
| 1863 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
| 1864 | 1864 | } |
| 1865 | 1865 | } |
| 1866 | 1866 | EE_Error::add_error( |
@@ -1870,7 +1870,7 @@ discard block |
||
| 1870 | 1870 | 'event_espresso' |
| 1871 | 1871 | ), |
| 1872 | 1872 | '<br/>', |
| 1873 | - implode( '<br/>', $error_strings ) |
|
| 1873 | + implode('<br/>', $error_strings) |
|
| 1874 | 1874 | ), |
| 1875 | 1875 | __FILE__, |
| 1876 | 1876 | __FUNCTION__, |
@@ -1889,7 +1889,7 @@ discard block |
||
| 1889 | 1889 | } |
| 1890 | 1890 | } else { |
| 1891 | 1891 | EE_Error::add_error( |
| 1892 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
| 1892 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
| 1893 | 1893 | __FILE__, |
| 1894 | 1894 | __FUNCTION__, |
| 1895 | 1895 | __LINE__ |
@@ -1928,7 +1928,7 @@ discard block |
||
| 1928 | 1928 | // save the TXN ( which clears cached copy of primary_registration) |
| 1929 | 1929 | $this->checkout->transaction->save(); |
| 1930 | 1930 | // grab TXN ID and save it to the primary_registration |
| 1931 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
| 1931 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
| 1932 | 1932 | // save what we have so far |
| 1933 | 1933 | $primary_registration->save(); |
| 1934 | 1934 | return true; |
@@ -1946,7 +1946,7 @@ discard block |
||
| 1946 | 1946 | private function _capture_primary_registration_data_from_billing_form() { |
| 1947 | 1947 | // convert billing form data into an attendee |
| 1948 | 1948 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
| 1949 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
| 1949 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
| 1950 | 1950 | EE_Error::add_error( |
| 1951 | 1951 | sprintf( |
| 1952 | 1952 | __( |
@@ -1954,7 +1954,7 @@ discard block |
||
| 1954 | 1954 | 'event_espresso' |
| 1955 | 1955 | ), |
| 1956 | 1956 | '<br/>', |
| 1957 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1957 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1958 | 1958 | ), |
| 1959 | 1959 | __FILE__, |
| 1960 | 1960 | __FUNCTION__, |
@@ -1963,7 +1963,7 @@ discard block |
||
| 1963 | 1963 | return false; |
| 1964 | 1964 | } |
| 1965 | 1965 | $primary_registration = $this->checkout->transaction->primary_registration(); |
| 1966 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
| 1966 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
| 1967 | 1967 | EE_Error::add_error( |
| 1968 | 1968 | sprintf( |
| 1969 | 1969 | __( |
@@ -1971,7 +1971,7 @@ discard block |
||
| 1971 | 1971 | 'event_espresso' |
| 1972 | 1972 | ), |
| 1973 | 1973 | '<br/>', |
| 1974 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1974 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1975 | 1975 | ), |
| 1976 | 1976 | __FILE__, |
| 1977 | 1977 | __FUNCTION__, |
@@ -1979,7 +1979,7 @@ discard block |
||
| 1979 | 1979 | ); |
| 1980 | 1980 | return false; |
| 1981 | 1981 | } |
| 1982 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
| 1982 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
| 1983 | 1983 | instanceof |
| 1984 | 1984 | EE_Attendee |
| 1985 | 1985 | ) { |
@@ -1990,7 +1990,7 @@ discard block |
||
| 1990 | 1990 | 'event_espresso' |
| 1991 | 1991 | ), |
| 1992 | 1992 | '<br/>', |
| 1993 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 1993 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1994 | 1994 | ), |
| 1995 | 1995 | __FILE__, |
| 1996 | 1996 | __FUNCTION__, |
@@ -1999,9 +1999,9 @@ discard block |
||
| 1999 | 1999 | return false; |
| 2000 | 2000 | } |
| 2001 | 2001 | /** @type EE_Registration_Processor $registration_processor */ |
| 2002 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
| 2002 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 2003 | 2003 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
| 2004 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
| 2004 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
| 2005 | 2005 | return true; |
| 2006 | 2006 | } |
| 2007 | 2007 | |
@@ -2016,22 +2016,22 @@ discard block |
||
| 2016 | 2016 | * @throws \EE_Error |
| 2017 | 2017 | */ |
| 2018 | 2018 | private function _get_payment_method_for_selected_method_of_payment() { |
| 2019 | - if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) { |
|
| 2019 | + if ($this->checkout->selected_method_of_payment === 'events_sold_out') { |
|
| 2020 | 2020 | $this->_redirect_because_event_sold_out(); |
| 2021 | 2021 | return null; |
| 2022 | 2022 | } |
| 2023 | 2023 | // get EE_Payment_Method object |
| 2024 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
| 2025 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
| 2024 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
| 2025 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
| 2026 | 2026 | } else { |
| 2027 | 2027 | // load EEM_Payment_Method |
| 2028 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
| 2028 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 2029 | 2029 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
| 2030 | 2030 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
| 2031 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
| 2031 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
| 2032 | 2032 | } |
| 2033 | 2033 | // verify $payment_method |
| 2034 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
| 2034 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
| 2035 | 2035 | // not a payment |
| 2036 | 2036 | EE_Error::add_error( |
| 2037 | 2037 | sprintf( |
@@ -2040,7 +2040,7 @@ discard block |
||
| 2040 | 2040 | 'event_espresso' |
| 2041 | 2041 | ), |
| 2042 | 2042 | '<br/>', |
| 2043 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 2043 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2044 | 2044 | ), |
| 2045 | 2045 | __FILE__, |
| 2046 | 2046 | __FUNCTION__, |
@@ -2049,7 +2049,7 @@ discard block |
||
| 2049 | 2049 | return null; |
| 2050 | 2050 | } |
| 2051 | 2051 | // and verify it has a valid Payment_Method Type object |
| 2052 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
| 2052 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 2053 | 2053 | // not a payment |
| 2054 | 2054 | EE_Error::add_error( |
| 2055 | 2055 | sprintf( |
@@ -2058,7 +2058,7 @@ discard block |
||
| 2058 | 2058 | 'event_espresso' |
| 2059 | 2059 | ), |
| 2060 | 2060 | '<br/>', |
| 2061 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 2061 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2062 | 2062 | ), |
| 2063 | 2063 | __FILE__, |
| 2064 | 2064 | __FUNCTION__, |
@@ -2079,29 +2079,29 @@ discard block |
||
| 2079 | 2079 | * @return mixed EE_Payment | boolean |
| 2080 | 2080 | * @throws \EE_Error |
| 2081 | 2081 | */ |
| 2082 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
| 2082 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
| 2083 | 2083 | $payment = null; |
| 2084 | 2084 | $this->checkout->transaction->save(); |
| 2085 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
| 2086 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
| 2085 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 2086 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
| 2087 | 2087 | return false; |
| 2088 | 2088 | } |
| 2089 | 2089 | try { |
| 2090 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
| 2090 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
| 2091 | 2091 | // generate payment object |
| 2092 | 2092 | $payment = $payment_processor->process_payment( |
| 2093 | 2093 | $payment_method, |
| 2094 | 2094 | $this->checkout->transaction, |
| 2095 | 2095 | $this->checkout->amount_owing, |
| 2096 | 2096 | $this->checkout->billing_form, |
| 2097 | - $this->_get_return_url( $payment_method ), |
|
| 2097 | + $this->_get_return_url($payment_method), |
|
| 2098 | 2098 | 'CART', |
| 2099 | 2099 | $this->checkout->admin_request, |
| 2100 | 2100 | true, |
| 2101 | 2101 | $this->reg_step_url() |
| 2102 | 2102 | ); |
| 2103 | - } catch ( Exception $e ) { |
|
| 2104 | - $this->_handle_payment_processor_exception( $e ); |
|
| 2103 | + } catch (Exception $e) { |
|
| 2104 | + $this->_handle_payment_processor_exception($e); |
|
| 2105 | 2105 | } |
| 2106 | 2106 | return $payment; |
| 2107 | 2107 | } |
@@ -2116,7 +2116,7 @@ discard block |
||
| 2116 | 2116 | * @return void |
| 2117 | 2117 | * @throws \EE_Error |
| 2118 | 2118 | */ |
| 2119 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
| 2119 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
| 2120 | 2120 | EE_Error::add_error( |
| 2121 | 2121 | sprintf( |
| 2122 | 2122 | __( |
@@ -2124,7 +2124,7 @@ discard block |
||
| 2124 | 2124 | 'event_espresso' |
| 2125 | 2125 | ), |
| 2126 | 2126 | '<br/>', |
| 2127 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
| 2127 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
| 2128 | 2128 | $e->getMessage(), |
| 2129 | 2129 | $e->getFile(), |
| 2130 | 2130 | $e->getLine() |
@@ -2145,9 +2145,9 @@ discard block |
||
| 2145 | 2145 | * @return string |
| 2146 | 2146 | * @throws \EE_Error |
| 2147 | 2147 | */ |
| 2148 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
| 2148 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
| 2149 | 2149 | $return_url = ''; |
| 2150 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
| 2150 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
| 2151 | 2151 | case EE_PMT_Base::offsite : |
| 2152 | 2152 | $return_url = add_query_arg( |
| 2153 | 2153 | array( |
@@ -2176,12 +2176,12 @@ discard block |
||
| 2176 | 2176 | * @return EE_Payment | FALSE |
| 2177 | 2177 | * @throws \EE_Error |
| 2178 | 2178 | */ |
| 2179 | - private function _validate_payment( $payment = null ) { |
|
| 2180 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
| 2179 | + private function _validate_payment($payment = null) { |
|
| 2180 | + if ($this->checkout->payment_method->is_off_line()) { |
|
| 2181 | 2181 | return true; |
| 2182 | 2182 | } |
| 2183 | 2183 | // verify payment object |
| 2184 | - if ( ! $payment instanceof EE_Payment ) { |
|
| 2184 | + if ( ! $payment instanceof EE_Payment) { |
|
| 2185 | 2185 | // not a payment |
| 2186 | 2186 | EE_Error::add_error( |
| 2187 | 2187 | sprintf( |
@@ -2190,7 +2190,7 @@ discard block |
||
| 2190 | 2190 | 'event_espresso' |
| 2191 | 2191 | ), |
| 2192 | 2192 | '<br/>', |
| 2193 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 2193 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2194 | 2194 | ), |
| 2195 | 2195 | __FILE__, |
| 2196 | 2196 | __FUNCTION__, |
@@ -2211,27 +2211,27 @@ discard block |
||
| 2211 | 2211 | * @return bool |
| 2212 | 2212 | * @throws \EE_Error |
| 2213 | 2213 | */ |
| 2214 | - private function _post_payment_processing( $payment = null ) { |
|
| 2214 | + private function _post_payment_processing($payment = null) { |
|
| 2215 | 2215 | // Off-Line payment? |
| 2216 | - if ( $payment === true ) { |
|
| 2216 | + if ($payment === true) { |
|
| 2217 | 2217 | //$this->_setup_redirect_for_next_step(); |
| 2218 | 2218 | return true; |
| 2219 | 2219 | // On-Site payment? |
| 2220 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
| 2221 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
| 2220 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
| 2221 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
| 2222 | 2222 | //$this->_setup_redirect_for_next_step(); |
| 2223 | 2223 | $this->checkout->continue_reg = false; |
| 2224 | 2224 | } |
| 2225 | 2225 | // Off-Site payment? |
| 2226 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
| 2226 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
| 2227 | 2227 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
| 2228 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
| 2229 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
| 2228 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
| 2229 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
| 2230 | 2230 | $this->checkout->redirect = true; |
| 2231 | 2231 | $this->checkout->redirect_form = $payment->redirect_form(); |
| 2232 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
| 2232 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
| 2233 | 2233 | // set JSON response |
| 2234 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
| 2234 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
| 2235 | 2235 | // set cron job for finalizing the TXN |
| 2236 | 2236 | // in case the user does not return from the off-site gateway |
| 2237 | 2237 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -2239,7 +2239,7 @@ discard block |
||
| 2239 | 2239 | $this->checkout->transaction->ID() |
| 2240 | 2240 | ); |
| 2241 | 2241 | // and lastly, let's bump the payment status to pending |
| 2242 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
| 2242 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
| 2243 | 2243 | $payment->save(); |
| 2244 | 2244 | } else { |
| 2245 | 2245 | // not a payment |
@@ -2251,7 +2251,7 @@ discard block |
||
| 2251 | 2251 | 'event_espresso' |
| 2252 | 2252 | ), |
| 2253 | 2253 | '<br/>', |
| 2254 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 2254 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2255 | 2255 | ), |
| 2256 | 2256 | __FILE__, |
| 2257 | 2257 | __FUNCTION__, |
@@ -2289,21 +2289,21 @@ discard block |
||
| 2289 | 2289 | * @return bool |
| 2290 | 2290 | * @throws \EE_Error |
| 2291 | 2291 | */ |
| 2292 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
| 2292 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
| 2293 | 2293 | // off-line payment? carry on |
| 2294 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
| 2294 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
| 2295 | 2295 | return true; |
| 2296 | 2296 | } |
| 2297 | 2297 | // verify payment validity |
| 2298 | - if ( $payment instanceof EE_Payment ) { |
|
| 2299 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
| 2298 | + if ($payment instanceof EE_Payment) { |
|
| 2299 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
| 2300 | 2300 | $msg = $payment->gateway_response(); |
| 2301 | 2301 | // check results |
| 2302 | - switch ( $payment->status() ) { |
|
| 2302 | + switch ($payment->status()) { |
|
| 2303 | 2303 | // good payment |
| 2304 | 2304 | case EEM_Payment::status_id_approved : |
| 2305 | 2305 | EE_Error::add_success( |
| 2306 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
| 2306 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
| 2307 | 2307 | __FILE__, |
| 2308 | 2308 | __FUNCTION__, |
| 2309 | 2309 | __LINE__ |
@@ -2312,45 +2312,45 @@ discard block |
||
| 2312 | 2312 | break; |
| 2313 | 2313 | // slow payment |
| 2314 | 2314 | case EEM_Payment::status_id_pending : |
| 2315 | - if ( empty( $msg ) ) { |
|
| 2315 | + if (empty($msg)) { |
|
| 2316 | 2316 | $msg = __( |
| 2317 | 2317 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
| 2318 | 2318 | 'event_espresso' |
| 2319 | 2319 | ); |
| 2320 | 2320 | } |
| 2321 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2321 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2322 | 2322 | return true; |
| 2323 | 2323 | break; |
| 2324 | 2324 | // don't wanna payment |
| 2325 | 2325 | case EEM_Payment::status_id_cancelled : |
| 2326 | - if ( empty( $msg ) ) { |
|
| 2326 | + if (empty($msg)) { |
|
| 2327 | 2327 | $msg = _n( |
| 2328 | 2328 | 'Payment cancelled. Please try again.', |
| 2329 | 2329 | 'Payment cancelled. Please try again or select another method of payment.', |
| 2330 | - count( $this->checkout->available_payment_methods ), |
|
| 2330 | + count($this->checkout->available_payment_methods), |
|
| 2331 | 2331 | 'event_espresso' |
| 2332 | 2332 | ); |
| 2333 | 2333 | } |
| 2334 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2334 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2335 | 2335 | return false; |
| 2336 | 2336 | break; |
| 2337 | 2337 | // not enough payment |
| 2338 | 2338 | case EEM_Payment::status_id_declined : |
| 2339 | - if ( empty( $msg ) ) { |
|
| 2339 | + if (empty($msg)) { |
|
| 2340 | 2340 | $msg = _n( |
| 2341 | 2341 | 'We\'re sorry but your payment was declined. Please try again.', |
| 2342 | 2342 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
| 2343 | - count( $this->checkout->available_payment_methods ), |
|
| 2343 | + count($this->checkout->available_payment_methods), |
|
| 2344 | 2344 | 'event_espresso' |
| 2345 | 2345 | ); |
| 2346 | 2346 | } |
| 2347 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2347 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2348 | 2348 | return false; |
| 2349 | 2349 | break; |
| 2350 | 2350 | // bad payment |
| 2351 | 2351 | case EEM_Payment::status_id_failed : |
| 2352 | - if ( ! empty( $msg ) ) { |
|
| 2353 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 2352 | + if ( ! empty($msg)) { |
|
| 2353 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2354 | 2354 | return false; |
| 2355 | 2355 | } |
| 2356 | 2356 | // default to error below |
@@ -2359,7 +2359,7 @@ discard block |
||
| 2359 | 2359 | } |
| 2360 | 2360 | // off-site payment gateway responses are too unreliable, so let's just assume that |
| 2361 | 2361 | // the payment processing is just running slower than the registrant's request |
| 2362 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
| 2362 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
| 2363 | 2363 | return true; |
| 2364 | 2364 | } |
| 2365 | 2365 | EE_Error::add_error( |
@@ -2369,7 +2369,7 @@ discard block |
||
| 2369 | 2369 | 'event_espresso' |
| 2370 | 2370 | ), |
| 2371 | 2371 | '<br/>', |
| 2372 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 2372 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2373 | 2373 | ), |
| 2374 | 2374 | __FILE__, |
| 2375 | 2375 | __FUNCTION__, |
@@ -2402,13 +2402,13 @@ discard block |
||
| 2402 | 2402 | public function process_gateway_response() { |
| 2403 | 2403 | $payment = null; |
| 2404 | 2404 | // how have they chosen to pay? |
| 2405 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
| 2405 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 2406 | 2406 | // get EE_Payment_Method object |
| 2407 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
| 2407 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 2408 | 2408 | $this->checkout->continue_reg = false; |
| 2409 | 2409 | return false; |
| 2410 | 2410 | } |
| 2411 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
| 2411 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
| 2412 | 2412 | return false; |
| 2413 | 2413 | } |
| 2414 | 2414 | $this->_validate_offsite_return(); |
@@ -2422,23 +2422,23 @@ discard block |
||
| 2422 | 2422 | // true |
| 2423 | 2423 | //); |
| 2424 | 2424 | // verify TXN |
| 2425 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
| 2425 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 2426 | 2426 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
| 2427 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
| 2427 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
| 2428 | 2428 | $this->checkout->continue_reg = false; |
| 2429 | 2429 | return false; |
| 2430 | 2430 | } |
| 2431 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
| 2432 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
| 2433 | - $payment = $this->_validate_payment( $payment ); |
|
| 2431 | + $payment = $this->_process_off_site_payment($gateway); |
|
| 2432 | + $payment = $this->_process_cancelled_payments($payment); |
|
| 2433 | + $payment = $this->_validate_payment($payment); |
|
| 2434 | 2434 | // if payment was not declined by the payment gateway or cancelled by the registrant |
| 2435 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
| 2435 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
| 2436 | 2436 | //$this->_setup_redirect_for_next_step(); |
| 2437 | 2437 | // store that for later |
| 2438 | 2438 | $this->checkout->payment = $payment; |
| 2439 | 2439 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
| 2440 | 2440 | // because we will complete this step during the IPN processing then |
| 2441 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
| 2441 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
| 2442 | 2442 | $this->set_completed(); |
| 2443 | 2443 | } |
| 2444 | 2444 | return true; |
@@ -2463,21 +2463,21 @@ discard block |
||
| 2463 | 2463 | * @throws \EE_Error |
| 2464 | 2464 | */ |
| 2465 | 2465 | private function _validate_offsite_return() { |
| 2466 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
| 2467 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
| 2466 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
| 2467 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
| 2468 | 2468 | // Houston... we might have a problem |
| 2469 | 2469 | $invalid_TXN = false; |
| 2470 | 2470 | // first gather some info |
| 2471 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
| 2471 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 2472 | 2472 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
| 2473 | 2473 | ? $valid_TXN->primary_registration() |
| 2474 | 2474 | : null; |
| 2475 | 2475 | // let's start by retrieving the cart for this TXN |
| 2476 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
| 2477 | - if ( $cart instanceof EE_Cart ) { |
|
| 2476 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
| 2477 | + if ($cart instanceof EE_Cart) { |
|
| 2478 | 2478 | // verify that the current cart has tickets |
| 2479 | 2479 | $tickets = $cart->get_tickets(); |
| 2480 | - if ( empty( $tickets ) ) { |
|
| 2480 | + if (empty($tickets)) { |
|
| 2481 | 2481 | $invalid_TXN = true; |
| 2482 | 2482 | } |
| 2483 | 2483 | } else { |
@@ -2503,21 +2503,21 @@ discard block |
||
| 2503 | 2503 | ) { |
| 2504 | 2504 | $invalid_TXN = true; |
| 2505 | 2505 | } |
| 2506 | - if ( $invalid_TXN ) { |
|
| 2506 | + if ($invalid_TXN) { |
|
| 2507 | 2507 | // is the valid TXN completed ? |
| 2508 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
| 2508 | + if ($valid_TXN instanceof EE_Transaction) { |
|
| 2509 | 2509 | // has this step even been started ? |
| 2510 | - $reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() ); |
|
| 2511 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
| 2510 | + $reg_step_completed = $valid_TXN->reg_step_completed($this->slug()); |
|
| 2511 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
| 2512 | 2512 | // so it **looks** like this is a double request from PayPal |
| 2513 | 2513 | // so let's try to pick up where we left off |
| 2514 | 2514 | $this->checkout->transaction = $valid_TXN; |
| 2515 | - $this->checkout->refresh_all_entities( true ); |
|
| 2515 | + $this->checkout->refresh_all_entities(true); |
|
| 2516 | 2516 | return; |
| 2517 | 2517 | } |
| 2518 | 2518 | } |
| 2519 | 2519 | // you appear to be lost? |
| 2520 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
| 2520 | + $this->_redirect_wayward_request($primary_registrant); |
|
| 2521 | 2521 | } |
| 2522 | 2522 | } |
| 2523 | 2523 | } |
@@ -2532,14 +2532,14 @@ discard block |
||
| 2532 | 2532 | * @return bool |
| 2533 | 2533 | * @throws \EE_Error |
| 2534 | 2534 | */ |
| 2535 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
| 2536 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
| 2535 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
| 2536 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
| 2537 | 2537 | // try redirecting based on the current TXN |
| 2538 | 2538 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
| 2539 | 2539 | ? $this->checkout->transaction->primary_registration() |
| 2540 | 2540 | : null; |
| 2541 | 2541 | } |
| 2542 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
| 2542 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
| 2543 | 2543 | EE_Error::add_error( |
| 2544 | 2544 | sprintf( |
| 2545 | 2545 | __( |
@@ -2547,7 +2547,7 @@ discard block |
||
| 2547 | 2547 | 'event_espresso' |
| 2548 | 2548 | ), |
| 2549 | 2549 | '<br/>', |
| 2550 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
| 2550 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2551 | 2551 | ), |
| 2552 | 2552 | __FILE__, |
| 2553 | 2553 | __FUNCTION__, |
@@ -2578,17 +2578,17 @@ discard block |
||
| 2578 | 2578 | * @return \EE_Payment |
| 2579 | 2579 | * @throws \EE_Error |
| 2580 | 2580 | */ |
| 2581 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
| 2581 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
| 2582 | 2582 | try { |
| 2583 | 2583 | $request_data = \EE_Registry::instance()->REQ->params(); |
| 2584 | 2584 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
| 2585 | 2585 | $this->set_handle_IPN_in_this_request( |
| 2586 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
| 2586 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
| 2587 | 2587 | ); |
| 2588 | - if ( $this->handle_IPN_in_this_request() ) { |
|
| 2588 | + if ($this->handle_IPN_in_this_request()) { |
|
| 2589 | 2589 | // get payment details and process results |
| 2590 | 2590 | /** @type EE_Payment_Processor $payment_processor */ |
| 2591 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
| 2591 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 2592 | 2592 | $payment = $payment_processor->process_ipn( |
| 2593 | 2593 | $request_data, |
| 2594 | 2594 | $this->checkout->transaction, |
@@ -2601,14 +2601,14 @@ discard block |
||
| 2601 | 2601 | $payment = $this->checkout->transaction->last_payment(); |
| 2602 | 2602 | //$payment_source = 'last_payment'; |
| 2603 | 2603 | } |
| 2604 | - } catch ( Exception $e ) { |
|
| 2604 | + } catch (Exception $e) { |
|
| 2605 | 2605 | // let's just eat the exception and try to move on using any previously set payment info |
| 2606 | 2606 | $payment = $this->checkout->transaction->last_payment(); |
| 2607 | 2607 | //$payment_source = 'last_payment after Exception'; |
| 2608 | 2608 | // but if we STILL don't have a payment object |
| 2609 | - if ( ! $payment instanceof EE_Payment ) { |
|
| 2609 | + if ( ! $payment instanceof EE_Payment) { |
|
| 2610 | 2610 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
| 2611 | - $this->_handle_payment_processor_exception( $e ); |
|
| 2611 | + $this->_handle_payment_processor_exception($e); |
|
| 2612 | 2612 | } |
| 2613 | 2613 | } |
| 2614 | 2614 | // DEBUG LOG |
@@ -2633,13 +2633,13 @@ discard block |
||
| 2633 | 2633 | * @return EE_Payment | FALSE |
| 2634 | 2634 | * @throws \EE_Error |
| 2635 | 2635 | */ |
| 2636 | - private function _process_cancelled_payments( $payment = null ) { |
|
| 2636 | + private function _process_cancelled_payments($payment = null) { |
|
| 2637 | 2637 | if ( |
| 2638 | 2638 | $payment instanceof EE_Payment |
| 2639 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
| 2639 | + && isset($_REQUEST['ee_cancel_payment']) |
|
| 2640 | 2640 | && $payment->status() === EEM_Payment::status_id_failed |
| 2641 | 2641 | ) { |
| 2642 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
| 2642 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
| 2643 | 2643 | } |
| 2644 | 2644 | return $payment; |
| 2645 | 2645 | } |
@@ -2656,14 +2656,14 @@ discard block |
||
| 2656 | 2656 | public function get_transaction_details_for_gateways() { |
| 2657 | 2657 | $txn_details = array(); |
| 2658 | 2658 | // ya gotta make a choice man |
| 2659 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
| 2659 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
| 2660 | 2660 | $txn_details = array( |
| 2661 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
| 2661 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
| 2662 | 2662 | ); |
| 2663 | 2663 | } |
| 2664 | 2664 | // get EE_Payment_Method object |
| 2665 | 2665 | if ( |
| 2666 | - empty( $txn_details ) |
|
| 2666 | + empty($txn_details) |
|
| 2667 | 2667 | && |
| 2668 | 2668 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
| 2669 | 2669 | ) { |
@@ -2675,8 +2675,8 @@ discard block |
||
| 2675 | 2675 | ) |
| 2676 | 2676 | ); |
| 2677 | 2677 | } |
| 2678 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
| 2679 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
| 2678 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
| 2679 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
| 2680 | 2680 | $txn_details = array( |
| 2681 | 2681 | 'TXN_ID' => $this->checkout->transaction->ID(), |
| 2682 | 2682 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2687,7 +2687,7 @@ discard block |
||
| 2687 | 2687 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
| 2688 | 2688 | 'payment_amount' => $this->checkout->amount_owing, |
| 2689 | 2689 | 'return_url' => $return_url, |
| 2690 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
| 2690 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
| 2691 | 2691 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
| 2692 | 2692 | array( |
| 2693 | 2693 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2696,7 +2696,7 @@ discard block |
||
| 2696 | 2696 | ) |
| 2697 | 2697 | ); |
| 2698 | 2698 | } |
| 2699 | - echo wp_json_encode( $txn_details ); |
|
| 2699 | + echo wp_json_encode($txn_details); |
|
| 2700 | 2700 | exit(); |
| 2701 | 2701 | } |
| 2702 | 2702 | |
@@ -2713,7 +2713,7 @@ discard block |
||
| 2713 | 2713 | public function __sleep() |
| 2714 | 2714 | { |
| 2715 | 2715 | // remove the reg form and the checkout |
| 2716 | - return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
| 2716 | + return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display')); |
|
| 2717 | 2717 | } |
| 2718 | 2718 | |
| 2719 | 2719 | |
@@ -32,49 +32,49 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * get_event |
|
| 37 | - * attempts to retrieve an EE_Event object any way it can |
|
| 38 | - * |
|
| 39 | - * @param int|WP_Post $EVT_ID |
|
| 40 | - * @return EE_Event|null |
|
| 41 | - * @throws \EE_Error |
|
| 42 | - */ |
|
| 35 | + /** |
|
| 36 | + * get_event |
|
| 37 | + * attempts to retrieve an EE_Event object any way it can |
|
| 38 | + * |
|
| 39 | + * @param int|WP_Post $EVT_ID |
|
| 40 | + * @return EE_Event|null |
|
| 41 | + * @throws \EE_Error |
|
| 42 | + */ |
|
| 43 | 43 | public static function get_event( $EVT_ID = 0 ) { |
| 44 | - // international newspaper? |
|
| 45 | - global $post; |
|
| 46 | - $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events' |
|
| 47 | - ? $EVT_ID->ID |
|
| 48 | - : absint($EVT_ID); |
|
| 49 | - // do we already have the Event you are looking for? |
|
| 50 | - if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
| 51 | - return EEH_Event_View::$_event; |
|
| 52 | - } |
|
| 53 | - //reset property so that the new event is cached. |
|
| 54 | - EEH_Event_View::$_event = null; |
|
| 55 | - |
|
| 56 | - if ($EVT_ID || $post instanceof WP_Post) { |
|
| 57 | - //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID |
|
| 58 | - //then let's just use that cached event on the $post object. |
|
| 59 | - if (($post instanceof WP_Post |
|
| 60 | - && $post->post_type === 'espresso_events' |
|
| 61 | - ) |
|
| 62 | - && isset($post->EE_Event) |
|
| 63 | - && ($EVT_ID === 0 |
|
| 64 | - || $EVT_ID === $post->ID |
|
| 65 | - ) |
|
| 66 | - ) { |
|
| 67 | - EEH_Event_View::$_event = $post->EE_Event; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID. |
|
| 71 | - if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
| 72 | - EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - return EEH_Event_View::$_event; |
|
| 77 | - } |
|
| 44 | + // international newspaper? |
|
| 45 | + global $post; |
|
| 46 | + $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events' |
|
| 47 | + ? $EVT_ID->ID |
|
| 48 | + : absint($EVT_ID); |
|
| 49 | + // do we already have the Event you are looking for? |
|
| 50 | + if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
| 51 | + return EEH_Event_View::$_event; |
|
| 52 | + } |
|
| 53 | + //reset property so that the new event is cached. |
|
| 54 | + EEH_Event_View::$_event = null; |
|
| 55 | + |
|
| 56 | + if ($EVT_ID || $post instanceof WP_Post) { |
|
| 57 | + //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID |
|
| 58 | + //then let's just use that cached event on the $post object. |
|
| 59 | + if (($post instanceof WP_Post |
|
| 60 | + && $post->post_type === 'espresso_events' |
|
| 61 | + ) |
|
| 62 | + && isset($post->EE_Event) |
|
| 63 | + && ($EVT_ID === 0 |
|
| 64 | + || $EVT_ID === $post->ID |
|
| 65 | + ) |
|
| 66 | + ) { |
|
| 67 | + EEH_Event_View::$_event = $post->EE_Event; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID. |
|
| 71 | + if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
| 72 | + EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + return EEH_Event_View::$_event; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | |
@@ -150,58 +150,58 @@ discard block |
||
| 150 | 150 | * @return string |
| 151 | 151 | */ |
| 152 | 152 | public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
| 153 | - global $post; |
|
| 153 | + global $post; |
|
| 154 | 154 | ob_start(); |
| 155 | 155 | if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
| 156 | 156 | // admin has chosen "full description" |
| 157 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 157 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 158 | 158 | the_content(); |
| 159 | 159 | } else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) { |
| 160 | - if ( has_excerpt( $post->ID )) { |
|
| 161 | - // admin has chosen "excerpt (short desc)" |
|
| 162 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 163 | - // AND an excerpt actually exists |
|
| 164 | - the_excerpt(); |
|
| 165 | - } else { |
|
| 166 | - // admin has chosen "excerpt (short desc)" |
|
| 167 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 168 | - // but NO excerpt actually exists, so we need to create one |
|
| 169 | - if ( ! empty( $num_words )) { |
|
| 170 | - if ( empty( $more )) { |
|
| 171 | - $more_link_text = __( '(more…)' ); |
|
| 172 | - $more = ' <a href="' . get_permalink() . '"'; |
|
| 173 | - $more .= ' class="more-link"'; |
|
| 174 | - $more .= \EED_Events_Archive::link_target(); |
|
| 175 | - $more .= '>' . $more_link_text . '</a>'; |
|
| 176 | - $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
| 177 | - } |
|
| 178 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
| 179 | - |
|
| 180 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
| 181 | - } else { |
|
| 182 | - $content = get_the_content(); |
|
| 183 | - } |
|
| 184 | - global $allowedtags; |
|
| 185 | - // make sure links are allowed |
|
| 186 | - $allowedtags['a'] = isset($allowedtags['a']) |
|
| 187 | - ? $allowedtags['a'] |
|
| 188 | - : array(); |
|
| 189 | - // as well as target attribute |
|
| 190 | - $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
| 191 | - ? $allowedtags['a']['target'] |
|
| 192 | - : false; |
|
| 193 | - // but get previous value so we can reset it |
|
| 194 | - $prev_value = $allowedtags['a']['target']; |
|
| 195 | - $allowedtags['a']['target'] = true; |
|
| 196 | - $content = wp_kses( $content, $allowedtags ); |
|
| 197 | - $content = strip_shortcodes( $content ); |
|
| 198 | - echo apply_filters( 'the_content', $content ); |
|
| 199 | - $allowedtags['a']['target'] = $prev_value; |
|
| 200 | - } |
|
| 201 | - } else { |
|
| 202 | - // admin has chosen "none" |
|
| 203 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 204 | - echo apply_filters( 'the_content', '' ); |
|
| 160 | + if ( has_excerpt( $post->ID )) { |
|
| 161 | + // admin has chosen "excerpt (short desc)" |
|
| 162 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 163 | + // AND an excerpt actually exists |
|
| 164 | + the_excerpt(); |
|
| 165 | + } else { |
|
| 166 | + // admin has chosen "excerpt (short desc)" |
|
| 167 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 168 | + // but NO excerpt actually exists, so we need to create one |
|
| 169 | + if ( ! empty( $num_words )) { |
|
| 170 | + if ( empty( $more )) { |
|
| 171 | + $more_link_text = __( '(more…)' ); |
|
| 172 | + $more = ' <a href="' . get_permalink() . '"'; |
|
| 173 | + $more .= ' class="more-link"'; |
|
| 174 | + $more .= \EED_Events_Archive::link_target(); |
|
| 175 | + $more .= '>' . $more_link_text . '</a>'; |
|
| 176 | + $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
| 177 | + } |
|
| 178 | + $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
| 179 | + |
|
| 180 | + $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
| 181 | + } else { |
|
| 182 | + $content = get_the_content(); |
|
| 183 | + } |
|
| 184 | + global $allowedtags; |
|
| 185 | + // make sure links are allowed |
|
| 186 | + $allowedtags['a'] = isset($allowedtags['a']) |
|
| 187 | + ? $allowedtags['a'] |
|
| 188 | + : array(); |
|
| 189 | + // as well as target attribute |
|
| 190 | + $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
| 191 | + ? $allowedtags['a']['target'] |
|
| 192 | + : false; |
|
| 193 | + // but get previous value so we can reset it |
|
| 194 | + $prev_value = $allowedtags['a']['target']; |
|
| 195 | + $allowedtags['a']['target'] = true; |
|
| 196 | + $content = wp_kses( $content, $allowedtags ); |
|
| 197 | + $content = strip_shortcodes( $content ); |
|
| 198 | + echo apply_filters( 'the_content', $content ); |
|
| 199 | + $allowedtags['a']['target'] = $prev_value; |
|
| 200 | + } |
|
| 201 | + } else { |
|
| 202 | + // admin has chosen "none" |
|
| 203 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 204 | + echo apply_filters( 'the_content', '' ); |
|
| 205 | 205 | } |
| 206 | 206 | return ob_get_clean(); |
| 207 | 207 | } |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | $url = get_term_link( $term, 'espresso_venue_categories' ); |
| 249 | 249 | if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
| 250 | 250 | $category_links[] = '<a href="' . esc_url( $url ) |
| 251 | - . '" rel="tag"' |
|
| 252 | - . \EED_Events_Archive::link_target() |
|
| 253 | - .'>' |
|
| 254 | - . $term->name |
|
| 255 | - . '</a>'; |
|
| 251 | + . '" rel="tag"' |
|
| 252 | + . \EED_Events_Archive::link_target() |
|
| 253 | + .'>' |
|
| 254 | + . $term->name |
|
| 255 | + . '</a>'; |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | <ul class="wp-people-group" id="ee-people-group-owners"> |
| 4 | 4 | <li class="wp-person" id="ee-person-sshoultes"> |
| 5 | 5 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 6 | - <?php echo esp_gravatar_image( '[email protected]', 'Seth Shoultes' ); ?> |
|
| 6 | + <?php echo esp_gravatar_image('[email protected]', 'Seth Shoultes'); ?> |
|
| 7 | 7 | </a> |
| 8 | 8 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 9 | 9 | Seth Shoultes |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | </li> |
| 13 | 13 | <li class="wp-person" id="ee-person-gkoyle"> |
| 14 | 14 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 15 | - <?php echo esp_gravatar_image( '[email protected]', 'Garth Koyle' ); ?> |
|
| 15 | + <?php echo esp_gravatar_image('[email protected]', 'Garth Koyle'); ?> |
|
| 16 | 16 | </a> |
| 17 | 17 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 18 | 18 | Garth Koyle |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | <ul class="wp-people-group" id="ee-people-group-core-developers"> |
| 25 | 25 | <li class="wp-person" id="ee-person-bchristensen"> |
| 26 | 26 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 27 | - <?php echo esp_gravatar_image( '[email protected]', 'Brent Christensen' ); ?> |
|
| 27 | + <?php echo esp_gravatar_image('[email protected]', 'Brent Christensen'); ?> |
|
| 28 | 28 | </a> |
| 29 | 29 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 30 | 30 | Brent Christensen |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | </li> |
| 34 | 34 | <li class="wp-person" id="ee-person-dethier"> |
| 35 | 35 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 36 | - <?php echo esp_gravatar_image( '[email protected]', 'Darren Ethier' ); ?> |
|
| 36 | + <?php echo esp_gravatar_image('[email protected]', 'Darren Ethier'); ?> |
|
| 37 | 37 | </a> |
| 38 | 38 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 39 | 39 | Darren Ethier |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | </li> |
| 43 | 43 | <li class="wp-person" id="ee-person-mnelson"> |
| 44 | 44 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 45 | - <?php echo esp_gravatar_image( '[email protected]', 'Michael Nelson' ); ?> |
|
| 45 | + <?php echo esp_gravatar_image('[email protected]', 'Michael Nelson'); ?> |
|
| 46 | 46 | </a> |
| 47 | 47 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 48 | 48 | Michael Nelson |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | </li> |
| 52 | 52 | <li class="wp-person" id="ee-person-nkolivoshka"> |
| 53 | 53 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 54 | - <?php echo esp_gravatar_image( '[email protected]', 'Nazar Kolivoshka' ); ?> |
|
| 54 | + <?php echo esp_gravatar_image('[email protected]', 'Nazar Kolivoshka'); ?> |
|
| 55 | 55 | </a> |
| 56 | 56 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 57 | 57 | Nazar Kolivoshka |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | <ul class="wp-people-group" id="ee-people-group-support-staff"> |
| 64 | 64 | <li class="wp-person" id="ee-person-jfeck"> |
| 65 | 65 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 66 | - <?php echo esp_gravatar_image( '[email protected]', 'Josh Feck' ); ?> |
|
| 66 | + <?php echo esp_gravatar_image('[email protected]', 'Josh Feck'); ?> |
|
| 67 | 67 | </a> |
| 68 | 68 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 69 | 69 | Josh Feck |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | </li> |
| 72 | 72 | <li class="wp-person" id="ee-person-twarwick"> |
| 73 | 73 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 74 | - <?php echo esp_gravatar_image( '[email protected]', 'Tony Warwick' ); ?> |
|
| 74 | + <?php echo esp_gravatar_image('[email protected]', 'Tony Warwick'); ?> |
|
| 75 | 75 | </a> |
| 76 | 76 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 77 | 77 | Tony Warwick |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | </li> |
| 80 | 80 | <li class="wp-person" id="ee-person-lcaum"> |
| 81 | 81 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 82 | - <?php echo esp_gravatar_image( '[email protected]', 'Lorenzo Caum' ); ?> |
|
| 82 | + <?php echo esp_gravatar_image('[email protected]', 'Lorenzo Caum'); ?> |
|
| 83 | 83 | </a> |
| 84 | 84 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
| 85 | 85 | Lorenzo Caum |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | </ul> |
| 90 | 90 | <h3 class="wp-people-group"><?php _e('Contributor Recognition', 'event_espresso'); ?></h3> |
| 91 | 91 | <p class="description"> |
| 92 | - <?php printf( __('For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.', 'event_espresso'), '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', '</a>' ); ?> |
|
| 92 | + <?php printf(__('For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.', 'event_espresso'), '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', '</a>'); ?> |
|
| 93 | 93 | </p> |
| 94 | 94 | <p class="wp-credits-list"> |
| 95 | 95 | <ul> |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | </p> |
| 104 | 104 | <h3 class="wp-people-group"><?php _e('External Libraries', 'event_espresso'); ?></h3> |
| 105 | 105 | <p class="description"> |
| 106 | - <?php printf( __('Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', 'event_espresso'), '<a href="credits.php">', '</a>' ); ?> |
|
| 106 | + <?php printf(__('Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', 'event_espresso'), '<a href="credits.php">', '</a>'); ?> |
|
| 107 | 107 | </p> |
| 108 | 108 | <p class="wp-credits-list"> |
| 109 | 109 | <a href="http://josscrowcroft.github.io/accounting.js/"><?php _e('accounting.js', 'event_espresso'); ?></a>, |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | <?php |
| 121 | 121 | function esp_gravatar_profile($email) { |
| 122 | - echo 'http://www.gravatar.com/' . md5($email); |
|
| 122 | + echo 'http://www.gravatar.com/'.md5($email); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | function esp_gravatar_image($email, $name) { |
| 126 | - echo '<img src="http://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
| 126 | + echo '<img src="http://0.gravatar.com/avatar/'.md5($email).'?s=60" class="gravatar" alt="'.$name.'"/>'; |
|
| 127 | 127 | } |
| 128 | 128 | ?> |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @param array $query_params like EEM_Base::get_all |
| 207 | 207 | * @param string $field_to_sum |
| 208 | - * @return int |
|
| 208 | + * @return double |
|
| 209 | 209 | */ |
| 210 | 210 | public function sum_deleted($query_params = null, $field_to_sum = null) |
| 211 | 211 | { |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
| 271 | 271 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
| 272 | 272 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
| 273 | - * @return boolean success |
|
| 273 | + * @return integer success |
|
| 274 | 274 | */ |
| 275 | 275 | public function delete_permanently($query_params = array(), $allow_blocking = true) |
| 276 | 276 | { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
| 5 | 5 | |
@@ -32,362 +32,362 @@ discard block |
||
| 32 | 32 | abstract class EEM_Soft_Delete_Base extends EEM_Base |
| 33 | 33 | { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param null $timezone |
|
| 37 | - */ |
|
| 38 | - protected function __construct($timezone = null) |
|
| 39 | - { |
|
| 40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
| 41 | - $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
| 42 | - } |
|
| 43 | - parent::__construct($timezone); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
| 50 | - * returns it's name. |
|
| 51 | - * |
|
| 52 | - * @return string |
|
| 53 | - * @throws EE_Error |
|
| 54 | - */ |
|
| 55 | - public function deleted_field_name() |
|
| 56 | - { |
|
| 57 | - $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
| 58 | - if ($field) { |
|
| 59 | - return $field->get_name(); |
|
| 60 | - } else { |
|
| 61 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
| 62 | - 'event_espresso'), get_class($this), get_class($this))); |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Gets one item that's been deleted, according to $query_params |
|
| 70 | - * |
|
| 71 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
| 72 | - * @return EE_Soft_Delete_Base_Class |
|
| 73 | - */ |
|
| 74 | - public function get_one_deleted($query_params = array()) |
|
| 75 | - { |
|
| 76 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 77 | - return parent::get_one($query_params); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
| 84 | - * |
|
| 85 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
| 86 | - * @return EE_Soft_Delete_Base_Class |
|
| 87 | - */ |
|
| 88 | - public function get_one_deleted_or_undeleted($query_params = array()) |
|
| 89 | - { |
|
| 90 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 91 | - return parent::get_one($query_params); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
| 98 | - * |
|
| 99 | - * @param int|string $id |
|
| 100 | - * @return EE_Soft_Delete_Base_Class |
|
| 101 | - */ |
|
| 102 | - public function get_one_by_ID_but_ignore_deleted($id) |
|
| 103 | - { |
|
| 104 | - return $this->get_one( |
|
| 105 | - $this->alter_query_params_to_restrict_by_ID( |
|
| 106 | - $id, |
|
| 107 | - array('default_where_conditions' => 'default') |
|
| 108 | - ) |
|
| 109 | - ); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Counts all the deleted/trashed items |
|
| 116 | - * |
|
| 117 | - * @param array $query_params like EEM_Base::get_all |
|
| 118 | - * @param string $field_to_count |
|
| 119 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
| 120 | - * @return int |
|
| 121 | - */ |
|
| 122 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
| 123 | - { |
|
| 124 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 125 | - return parent::count($query_params, $field_to_count, $distinct); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
| 132 | - * |
|
| 133 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
| 134 | - * @return array like EEM_Base::get_all's $query_params |
|
| 135 | - */ |
|
| 136 | - protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
| 137 | - { |
|
| 138 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
| 139 | - $query_params[0][$deletedFlagFieldName] = true; |
|
| 140 | - return $query_params; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
| 147 | - * |
|
| 148 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
| 149 | - * @return array like EEM_Base::get_all's $query_params |
|
| 150 | - */ |
|
| 151 | - public function alter_query_params_so_only_trashed_items_included($query_params) |
|
| 152 | - { |
|
| 153 | - return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * Alters the query params so each item's deleted status is ignored. |
|
| 160 | - * |
|
| 161 | - * @param array $query_params |
|
| 162 | - * @return array |
|
| 163 | - */ |
|
| 164 | - public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
| 165 | - { |
|
| 166 | - return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Alters the query params so each item's deleted status is ignored. |
|
| 173 | - * |
|
| 174 | - * @param array $query_params |
|
| 175 | - * @return array |
|
| 176 | - */ |
|
| 177 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
| 178 | - { |
|
| 179 | - if (! isset($query_params['default_where_conditions'])) { |
|
| 180 | - $query_params['default_where_conditions'] = 'minimum'; |
|
| 181 | - } |
|
| 182 | - return $query_params; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Counts all deleted and undeleted items |
|
| 189 | - * |
|
| 190 | - * @param array $query_params like EEM_Base::get_all |
|
| 191 | - * @param string $field_to_count |
|
| 192 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
| 193 | - * @return int |
|
| 194 | - */ |
|
| 195 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
| 196 | - { |
|
| 197 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 198 | - return parent::count($query_params, $field_to_count, $distinct); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Sum all the deleted items. |
|
| 205 | - * |
|
| 206 | - * @param array $query_params like EEM_Base::get_all |
|
| 207 | - * @param string $field_to_sum |
|
| 208 | - * @return int |
|
| 209 | - */ |
|
| 210 | - public function sum_deleted($query_params = null, $field_to_sum = null) |
|
| 211 | - { |
|
| 212 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 213 | - return parent::sum($query_params, $field_to_sum); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * Sums all the deleted and undeleted items. |
|
| 220 | - * |
|
| 221 | - * @param array $query_params lik eEEM_Base::get_all |
|
| 222 | - * @param string $field_to_sum |
|
| 223 | - * @return int |
|
| 224 | - */ |
|
| 225 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
| 226 | - { |
|
| 227 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 228 | - parent::sum($query_params, $field_to_sum); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
| 235 | - * whether they've been soft-deleted or not |
|
| 236 | - * |
|
| 237 | - * @param array $query_params like EEM_Base::get_all |
|
| 238 | - * @return EE_Soft_Delete_Base_Class[] |
|
| 239 | - */ |
|
| 240 | - public function get_all_deleted_and_undeleted($query_params = array()) |
|
| 241 | - { |
|
| 242 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 243 | - return parent::get_all($query_params); |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
| 250 | - * |
|
| 251 | - * @param array $query_params like EEM_Base::get_all |
|
| 252 | - * @return EE_Soft_Delete_Base_Class[] |
|
| 253 | - */ |
|
| 254 | - public function get_all_deleted($query_params = array()) |
|
| 255 | - { |
|
| 256 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 257 | - return parent::get_all($query_params); |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
| 264 | - * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
| 265 | - * before you can permanently delete them). |
|
| 266 | - * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
| 267 | - * and abort the delete) |
|
| 268 | - * |
|
| 269 | - * @param array $query_params like EEM_Base::get_all |
|
| 270 | - * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
| 271 | - * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
| 272 | - * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
| 273 | - * @return boolean success |
|
| 274 | - */ |
|
| 275 | - public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
| 276 | - { |
|
| 277 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 278 | - return parent::delete_permanently($query_params, $allow_blocking); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
| 285 | - * has been soft-deleted or not. |
|
| 286 | - * |
|
| 287 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
| 288 | - * @return boolean success |
|
| 289 | - */ |
|
| 290 | - public function restore_by_ID($ID = false) |
|
| 291 | - { |
|
| 292 | - return $this->delete_or_restore_by_ID(false, $ID); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
| 299 | - * this function will ignore whether the items have been soft-deleted or not. |
|
| 300 | - * |
|
| 301 | - * @param boolean $delete true for delete, false for restore |
|
| 302 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
| 303 | - * @return boolean |
|
| 304 | - */ |
|
| 305 | - public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
| 306 | - { |
|
| 307 | - if (! $ID) { |
|
| 308 | - return false; |
|
| 309 | - } |
|
| 310 | - if ( |
|
| 311 | - $this->delete_or_restore( |
|
| 312 | - $delete, |
|
| 313 | - $this->alter_query_params_to_restrict_by_ID($ID) |
|
| 314 | - ) |
|
| 315 | - ) { |
|
| 316 | - return true; |
|
| 317 | - } else { |
|
| 318 | - return false; |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
| 326 | - * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
| 327 | - * Note: because this item will be soft-deleted only, |
|
| 328 | - * doesn't block because of model dependencies |
|
| 329 | - * |
|
| 330 | - * @param array $query_params like EEM_Base::get_all |
|
| 331 | - * @param bool $block_deletes |
|
| 332 | - * @return boolean |
|
| 333 | - */ |
|
| 334 | - public function delete($query_params = array(), $block_deletes = false) |
|
| 335 | - { |
|
| 336 | - //no matter what, we WON'T block soft deletes. |
|
| 337 | - return $this->delete_or_restore(true, $query_params); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
| 344 | - * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
| 345 | - * |
|
| 346 | - * @param array $query_params like EEM_Base::get_all |
|
| 347 | - * @return boolean |
|
| 348 | - */ |
|
| 349 | - public function restore($query_params = array()) |
|
| 350 | - { |
|
| 351 | - return $this->delete_or_restore(false, $query_params); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
| 358 | - * |
|
| 359 | - * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
| 360 | - * @param array $query_params like EEM_Base::get_all |
|
| 361 | - * @return boolean |
|
| 362 | - */ |
|
| 363 | - function delete_or_restore($delete = true, $query_params = array()) |
|
| 364 | - { |
|
| 365 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
| 366 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 367 | - if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
| 368 | - return true; |
|
| 369 | - } else { |
|
| 370 | - return false; |
|
| 371 | - } |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Updates all the items of this model which match the $query params, regardless of whether |
|
| 378 | - * they've been soft-deleted or not |
|
| 379 | - * |
|
| 380 | - * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
| 381 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
| 382 | - * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
| 383 | - * in this model's entity map according to $fields_n_values that match $query_params. This |
|
| 384 | - * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
| 385 | - * be aware that model objects being used could get out-of-sync with the database |
|
| 386 | - * @return int number of items updated |
|
| 387 | - */ |
|
| 388 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
| 389 | - { |
|
| 390 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 391 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
| 392 | - } |
|
| 35 | + /** |
|
| 36 | + * @param null $timezone |
|
| 37 | + */ |
|
| 38 | + protected function __construct($timezone = null) |
|
| 39 | + { |
|
| 40 | + if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
| 41 | + $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
| 42 | + } |
|
| 43 | + parent::__construct($timezone); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
| 50 | + * returns it's name. |
|
| 51 | + * |
|
| 52 | + * @return string |
|
| 53 | + * @throws EE_Error |
|
| 54 | + */ |
|
| 55 | + public function deleted_field_name() |
|
| 56 | + { |
|
| 57 | + $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
| 58 | + if ($field) { |
|
| 59 | + return $field->get_name(); |
|
| 60 | + } else { |
|
| 61 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
| 62 | + 'event_espresso'), get_class($this), get_class($this))); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Gets one item that's been deleted, according to $query_params |
|
| 70 | + * |
|
| 71 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
| 72 | + * @return EE_Soft_Delete_Base_Class |
|
| 73 | + */ |
|
| 74 | + public function get_one_deleted($query_params = array()) |
|
| 75 | + { |
|
| 76 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 77 | + return parent::get_one($query_params); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
| 84 | + * |
|
| 85 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
| 86 | + * @return EE_Soft_Delete_Base_Class |
|
| 87 | + */ |
|
| 88 | + public function get_one_deleted_or_undeleted($query_params = array()) |
|
| 89 | + { |
|
| 90 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 91 | + return parent::get_one($query_params); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
| 98 | + * |
|
| 99 | + * @param int|string $id |
|
| 100 | + * @return EE_Soft_Delete_Base_Class |
|
| 101 | + */ |
|
| 102 | + public function get_one_by_ID_but_ignore_deleted($id) |
|
| 103 | + { |
|
| 104 | + return $this->get_one( |
|
| 105 | + $this->alter_query_params_to_restrict_by_ID( |
|
| 106 | + $id, |
|
| 107 | + array('default_where_conditions' => 'default') |
|
| 108 | + ) |
|
| 109 | + ); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Counts all the deleted/trashed items |
|
| 116 | + * |
|
| 117 | + * @param array $query_params like EEM_Base::get_all |
|
| 118 | + * @param string $field_to_count |
|
| 119 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
| 120 | + * @return int |
|
| 121 | + */ |
|
| 122 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
| 123 | + { |
|
| 124 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 125 | + return parent::count($query_params, $field_to_count, $distinct); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
| 132 | + * |
|
| 133 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
| 134 | + * @return array like EEM_Base::get_all's $query_params |
|
| 135 | + */ |
|
| 136 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
| 137 | + { |
|
| 138 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
| 139 | + $query_params[0][$deletedFlagFieldName] = true; |
|
| 140 | + return $query_params; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
| 147 | + * |
|
| 148 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
| 149 | + * @return array like EEM_Base::get_all's $query_params |
|
| 150 | + */ |
|
| 151 | + public function alter_query_params_so_only_trashed_items_included($query_params) |
|
| 152 | + { |
|
| 153 | + return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * Alters the query params so each item's deleted status is ignored. |
|
| 160 | + * |
|
| 161 | + * @param array $query_params |
|
| 162 | + * @return array |
|
| 163 | + */ |
|
| 164 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
| 165 | + { |
|
| 166 | + return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Alters the query params so each item's deleted status is ignored. |
|
| 173 | + * |
|
| 174 | + * @param array $query_params |
|
| 175 | + * @return array |
|
| 176 | + */ |
|
| 177 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
| 178 | + { |
|
| 179 | + if (! isset($query_params['default_where_conditions'])) { |
|
| 180 | + $query_params['default_where_conditions'] = 'minimum'; |
|
| 181 | + } |
|
| 182 | + return $query_params; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Counts all deleted and undeleted items |
|
| 189 | + * |
|
| 190 | + * @param array $query_params like EEM_Base::get_all |
|
| 191 | + * @param string $field_to_count |
|
| 192 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
| 193 | + * @return int |
|
| 194 | + */ |
|
| 195 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
| 196 | + { |
|
| 197 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 198 | + return parent::count($query_params, $field_to_count, $distinct); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Sum all the deleted items. |
|
| 205 | + * |
|
| 206 | + * @param array $query_params like EEM_Base::get_all |
|
| 207 | + * @param string $field_to_sum |
|
| 208 | + * @return int |
|
| 209 | + */ |
|
| 210 | + public function sum_deleted($query_params = null, $field_to_sum = null) |
|
| 211 | + { |
|
| 212 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 213 | + return parent::sum($query_params, $field_to_sum); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * Sums all the deleted and undeleted items. |
|
| 220 | + * |
|
| 221 | + * @param array $query_params lik eEEM_Base::get_all |
|
| 222 | + * @param string $field_to_sum |
|
| 223 | + * @return int |
|
| 224 | + */ |
|
| 225 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
| 226 | + { |
|
| 227 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 228 | + parent::sum($query_params, $field_to_sum); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
| 235 | + * whether they've been soft-deleted or not |
|
| 236 | + * |
|
| 237 | + * @param array $query_params like EEM_Base::get_all |
|
| 238 | + * @return EE_Soft_Delete_Base_Class[] |
|
| 239 | + */ |
|
| 240 | + public function get_all_deleted_and_undeleted($query_params = array()) |
|
| 241 | + { |
|
| 242 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 243 | + return parent::get_all($query_params); |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
| 250 | + * |
|
| 251 | + * @param array $query_params like EEM_Base::get_all |
|
| 252 | + * @return EE_Soft_Delete_Base_Class[] |
|
| 253 | + */ |
|
| 254 | + public function get_all_deleted($query_params = array()) |
|
| 255 | + { |
|
| 256 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
| 257 | + return parent::get_all($query_params); |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
| 264 | + * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
| 265 | + * before you can permanently delete them). |
|
| 266 | + * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
| 267 | + * and abort the delete) |
|
| 268 | + * |
|
| 269 | + * @param array $query_params like EEM_Base::get_all |
|
| 270 | + * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
| 271 | + * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
| 272 | + * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
| 273 | + * @return boolean success |
|
| 274 | + */ |
|
| 275 | + public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
| 276 | + { |
|
| 277 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 278 | + return parent::delete_permanently($query_params, $allow_blocking); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
| 285 | + * has been soft-deleted or not. |
|
| 286 | + * |
|
| 287 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
| 288 | + * @return boolean success |
|
| 289 | + */ |
|
| 290 | + public function restore_by_ID($ID = false) |
|
| 291 | + { |
|
| 292 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
| 299 | + * this function will ignore whether the items have been soft-deleted or not. |
|
| 300 | + * |
|
| 301 | + * @param boolean $delete true for delete, false for restore |
|
| 302 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
| 303 | + * @return boolean |
|
| 304 | + */ |
|
| 305 | + public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
| 306 | + { |
|
| 307 | + if (! $ID) { |
|
| 308 | + return false; |
|
| 309 | + } |
|
| 310 | + if ( |
|
| 311 | + $this->delete_or_restore( |
|
| 312 | + $delete, |
|
| 313 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
| 314 | + ) |
|
| 315 | + ) { |
|
| 316 | + return true; |
|
| 317 | + } else { |
|
| 318 | + return false; |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
| 326 | + * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
| 327 | + * Note: because this item will be soft-deleted only, |
|
| 328 | + * doesn't block because of model dependencies |
|
| 329 | + * |
|
| 330 | + * @param array $query_params like EEM_Base::get_all |
|
| 331 | + * @param bool $block_deletes |
|
| 332 | + * @return boolean |
|
| 333 | + */ |
|
| 334 | + public function delete($query_params = array(), $block_deletes = false) |
|
| 335 | + { |
|
| 336 | + //no matter what, we WON'T block soft deletes. |
|
| 337 | + return $this->delete_or_restore(true, $query_params); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
| 344 | + * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
| 345 | + * |
|
| 346 | + * @param array $query_params like EEM_Base::get_all |
|
| 347 | + * @return boolean |
|
| 348 | + */ |
|
| 349 | + public function restore($query_params = array()) |
|
| 350 | + { |
|
| 351 | + return $this->delete_or_restore(false, $query_params); |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
| 358 | + * |
|
| 359 | + * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
| 360 | + * @param array $query_params like EEM_Base::get_all |
|
| 361 | + * @return boolean |
|
| 362 | + */ |
|
| 363 | + function delete_or_restore($delete = true, $query_params = array()) |
|
| 364 | + { |
|
| 365 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
| 366 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 367 | + if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
| 368 | + return true; |
|
| 369 | + } else { |
|
| 370 | + return false; |
|
| 371 | + } |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Updates all the items of this model which match the $query params, regardless of whether |
|
| 378 | + * they've been soft-deleted or not |
|
| 379 | + * |
|
| 380 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
| 381 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
| 382 | + * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
| 383 | + * in this model's entity map according to $fields_n_values that match $query_params. This |
|
| 384 | + * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
| 385 | + * be aware that model objects being used could get out-of-sync with the database |
|
| 386 | + * @return int number of items updated |
|
| 387 | + */ |
|
| 388 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
| 389 | + { |
|
| 390 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
| 391 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
| 392 | + } |
|
| 393 | 393 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
| 4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
| 5 | 5 | |
| 6 | 6 | |
| 7 | 7 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | protected function __construct($timezone = null) |
| 39 | 39 | { |
| 40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
| 40 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
| 41 | 41 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
| 42 | 42 | } |
| 43 | 43 | parent::__construct($timezone); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
| 178 | 178 | { |
| 179 | - if (! isset($query_params['default_where_conditions'])) { |
|
| 179 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
| 180 | 180 | $query_params['default_where_conditions'] = 'minimum'; |
| 181 | 181 | } |
| 182 | 182 | return $query_params; |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function delete_or_restore_by_ID($delete = true, $ID = false) |
| 306 | 306 | { |
| 307 | - if (! $ID) { |
|
| 307 | + if ( ! $ID) { |
|
| 308 | 308 | return false; |
| 309 | 309 | } |
| 310 | 310 | if ( |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('ABSPATH')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /* |
| 5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
| 40 | 40 | * @since 4.0 |
| 41 | 41 | */ |
| 42 | 42 | if (function_exists('espresso_version')) { |
| 43 | - /** |
|
| 44 | - * espresso_duplicate_plugin_error |
|
| 45 | - * displays if more than one version of EE is activated at the same time |
|
| 46 | - */ |
|
| 47 | - function espresso_duplicate_plugin_error() |
|
| 48 | - { |
|
| 49 | - ?> |
|
| 43 | + /** |
|
| 44 | + * espresso_duplicate_plugin_error |
|
| 45 | + * displays if more than one version of EE is activated at the same time |
|
| 46 | + */ |
|
| 47 | + function espresso_duplicate_plugin_error() |
|
| 48 | + { |
|
| 49 | + ?> |
|
| 50 | 50 | <div class="error"> |
| 51 | 51 | <p> |
| 52 | 52 | <?php echo esc_html__( |
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - /** |
|
| 97 | - * espresso_version |
|
| 98 | - * Returns the plugin version |
|
| 99 | - * |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - function espresso_version() |
|
| 103 | - { |
|
| 104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.40.rc.007'); |
|
| 105 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + /** |
|
| 97 | + * espresso_version |
|
| 98 | + * Returns the plugin version |
|
| 99 | + * |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + function espresso_version() |
|
| 103 | + { |
|
| 104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.40.rc.007'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // define versions |
|
| 108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | - if ( ! defined('DS')) { |
|
| 115 | - define('DS', '/'); |
|
| 116 | - } |
|
| 117 | - if ( ! defined('PS')) { |
|
| 118 | - define('PS', PATH_SEPARATOR); |
|
| 119 | - } |
|
| 120 | - if ( ! defined('SP')) { |
|
| 121 | - define('SP', ' '); |
|
| 122 | - } |
|
| 123 | - if ( ! defined('EENL')) { |
|
| 124 | - define('EENL', "\n"); |
|
| 125 | - } |
|
| 126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | - // define the plugin directory and URL |
|
| 128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | - // main root folder paths |
|
| 132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | - // core system paths |
|
| 141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | - // gateways |
|
| 154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | - // asset URL paths |
|
| 157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | - // define upload paths |
|
| 164 | - $uploads = wp_upload_dir(); |
|
| 165 | - // define the uploads directory and URL |
|
| 166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | - // define the templates directory and URL |
|
| 169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | - // define the gateway directory and URL |
|
| 172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | - // languages folder/path |
|
| 175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | - //check for dompdf fonts in uploads |
|
| 178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | - } |
|
| 181 | - //ajax constants |
|
| 182 | - define( |
|
| 183 | - 'EE_FRONT_AJAX', |
|
| 184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | - ); |
|
| 186 | - define( |
|
| 187 | - 'EE_ADMIN_AJAX', |
|
| 188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | - ); |
|
| 190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | - //want to change its default value! or find when -1 means infinity |
|
| 193 | - define('EE_INF_IN_DB', -1); |
|
| 194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | - define('EE_DEBUG', false); |
|
| 196 | - // for older WP versions |
|
| 197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | - } |
|
| 200 | - /** |
|
| 201 | - * espresso_plugin_activation |
|
| 202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | - */ |
|
| 204 | - function espresso_plugin_activation() |
|
| 205 | - { |
|
| 206 | - update_option('ee_espresso_activation', true); |
|
| 207 | - } |
|
| 107 | + // define versions |
|
| 108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | + if ( ! defined('DS')) { |
|
| 115 | + define('DS', '/'); |
|
| 116 | + } |
|
| 117 | + if ( ! defined('PS')) { |
|
| 118 | + define('PS', PATH_SEPARATOR); |
|
| 119 | + } |
|
| 120 | + if ( ! defined('SP')) { |
|
| 121 | + define('SP', ' '); |
|
| 122 | + } |
|
| 123 | + if ( ! defined('EENL')) { |
|
| 124 | + define('EENL', "\n"); |
|
| 125 | + } |
|
| 126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | + // define the plugin directory and URL |
|
| 128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | + // main root folder paths |
|
| 132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | + // core system paths |
|
| 141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | + // gateways |
|
| 154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | + // asset URL paths |
|
| 157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | + // define upload paths |
|
| 164 | + $uploads = wp_upload_dir(); |
|
| 165 | + // define the uploads directory and URL |
|
| 166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | + // define the templates directory and URL |
|
| 169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | + // define the gateway directory and URL |
|
| 172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | + // languages folder/path |
|
| 175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | + //check for dompdf fonts in uploads |
|
| 178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | + } |
|
| 181 | + //ajax constants |
|
| 182 | + define( |
|
| 183 | + 'EE_FRONT_AJAX', |
|
| 184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | + ); |
|
| 186 | + define( |
|
| 187 | + 'EE_ADMIN_AJAX', |
|
| 188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | + ); |
|
| 190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | + //want to change its default value! or find when -1 means infinity |
|
| 193 | + define('EE_INF_IN_DB', -1); |
|
| 194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | + define('EE_DEBUG', false); |
|
| 196 | + // for older WP versions |
|
| 197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | + } |
|
| 200 | + /** |
|
| 201 | + * espresso_plugin_activation |
|
| 202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | + */ |
|
| 204 | + function espresso_plugin_activation() |
|
| 205 | + { |
|
| 206 | + update_option('ee_espresso_activation', true); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | - /** |
|
| 211 | - * espresso_load_error_handling |
|
| 212 | - * this function loads EE's class for handling exceptions and errors |
|
| 213 | - */ |
|
| 214 | - function espresso_load_error_handling() |
|
| 215 | - { |
|
| 216 | - // load debugging tools |
|
| 217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | - EEH_Debug_Tools::instance(); |
|
| 220 | - } |
|
| 221 | - // load error handling |
|
| 222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | - } else { |
|
| 225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | - } |
|
| 227 | - } |
|
| 209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | + /** |
|
| 211 | + * espresso_load_error_handling |
|
| 212 | + * this function loads EE's class for handling exceptions and errors |
|
| 213 | + */ |
|
| 214 | + function espresso_load_error_handling() |
|
| 215 | + { |
|
| 216 | + // load debugging tools |
|
| 217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | + EEH_Debug_Tools::instance(); |
|
| 220 | + } |
|
| 221 | + // load error handling |
|
| 222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | + } else { |
|
| 225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * espresso_load_required |
|
| 231 | - * given a class name and path, this function will load that file or throw an exception |
|
| 232 | - * |
|
| 233 | - * @param string $classname |
|
| 234 | - * @param string $full_path_to_file |
|
| 235 | - * @throws EE_Error |
|
| 236 | - */ |
|
| 237 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | - { |
|
| 239 | - static $error_handling_loaded = false; |
|
| 240 | - if ( ! $error_handling_loaded) { |
|
| 241 | - espresso_load_error_handling(); |
|
| 242 | - $error_handling_loaded = true; |
|
| 243 | - } |
|
| 244 | - if (is_readable($full_path_to_file)) { |
|
| 245 | - require_once($full_path_to_file); |
|
| 246 | - } else { |
|
| 247 | - throw new EE_Error ( |
|
| 248 | - sprintf( |
|
| 249 | - esc_html__( |
|
| 250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | - 'event_espresso' |
|
| 252 | - ), |
|
| 253 | - $classname |
|
| 254 | - ) |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - } |
|
| 229 | + /** |
|
| 230 | + * espresso_load_required |
|
| 231 | + * given a class name and path, this function will load that file or throw an exception |
|
| 232 | + * |
|
| 233 | + * @param string $classname |
|
| 234 | + * @param string $full_path_to_file |
|
| 235 | + * @throws EE_Error |
|
| 236 | + */ |
|
| 237 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | + { |
|
| 239 | + static $error_handling_loaded = false; |
|
| 240 | + if ( ! $error_handling_loaded) { |
|
| 241 | + espresso_load_error_handling(); |
|
| 242 | + $error_handling_loaded = true; |
|
| 243 | + } |
|
| 244 | + if (is_readable($full_path_to_file)) { |
|
| 245 | + require_once($full_path_to_file); |
|
| 246 | + } else { |
|
| 247 | + throw new EE_Error ( |
|
| 248 | + sprintf( |
|
| 249 | + esc_html__( |
|
| 250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | + 'event_espresso' |
|
| 252 | + ), |
|
| 253 | + $classname |
|
| 254 | + ) |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | - new EE_Bootstrap(); |
|
| 263 | - } |
|
| 259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | + new EE_Bootstrap(); |
|
| 263 | + } |
|
| 264 | 264 | } |
| 265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
| 266 | - /** |
|
| 267 | - * deactivate_plugin |
|
| 268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | - * |
|
| 270 | - * @access public |
|
| 271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | - * @return void |
|
| 273 | - */ |
|
| 274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | - { |
|
| 276 | - if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | - } |
|
| 279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | - deactivate_plugins($plugin_basename); |
|
| 281 | - } |
|
| 266 | + /** |
|
| 267 | + * deactivate_plugin |
|
| 268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | + * |
|
| 270 | + * @access public |
|
| 271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | + * @return void |
|
| 273 | + */ |
|
| 274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | + { |
|
| 276 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | + } |
|
| 279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | + deactivate_plugins($plugin_basename); |
|
| 281 | + } |
|
| 282 | 282 | } |
| 283 | 283 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /** |
| 5 | 5 | * Event Espresso |
@@ -26,55 +26,55 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Overrides parent _delete() so that we do soft deletes. |
|
| 31 | - * |
|
| 32 | - * @return bool|int |
|
| 33 | - */ |
|
| 34 | - protected function _delete() |
|
| 35 | - { |
|
| 36 | - return $this->delete_or_restore(); |
|
| 37 | - } |
|
| 29 | + /** |
|
| 30 | + * Overrides parent _delete() so that we do soft deletes. |
|
| 31 | + * |
|
| 32 | + * @return bool|int |
|
| 33 | + */ |
|
| 34 | + protected function _delete() |
|
| 35 | + { |
|
| 36 | + return $this->delete_or_restore(); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Deletes or restores this object. |
|
| 43 | - * |
|
| 44 | - * @param bool $delete true=>delete, false=>restore |
|
| 45 | - * @return bool|int |
|
| 46 | - */ |
|
| 47 | - public function delete_or_restore($delete = true) |
|
| 48 | - { |
|
| 49 | - /** |
|
| 50 | - * Called just before trashing (soft delete) or restoring a trashed item. |
|
| 51 | - * |
|
| 52 | - * @param EE_Base_Class $model_object about to be trashed or restored |
|
| 53 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
| 54 | - */ |
|
| 55 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
| 56 | - $model = $this->get_model(); |
|
| 57 | - $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
| 58 | - /** |
|
| 59 | - * Called just after trashing (soft delete) or restoring a trashed item. |
|
| 60 | - * |
|
| 61 | - * @param EE_Base_Class $model_object that was just trashed or restored. |
|
| 62 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
| 63 | - * @param bool|int $result |
|
| 64 | - */ |
|
| 65 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
| 66 | - return $result; |
|
| 67 | - } |
|
| 41 | + /** |
|
| 42 | + * Deletes or restores this object. |
|
| 43 | + * |
|
| 44 | + * @param bool $delete true=>delete, false=>restore |
|
| 45 | + * @return bool|int |
|
| 46 | + */ |
|
| 47 | + public function delete_or_restore($delete = true) |
|
| 48 | + { |
|
| 49 | + /** |
|
| 50 | + * Called just before trashing (soft delete) or restoring a trashed item. |
|
| 51 | + * |
|
| 52 | + * @param EE_Base_Class $model_object about to be trashed or restored |
|
| 53 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
| 54 | + */ |
|
| 55 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
| 56 | + $model = $this->get_model(); |
|
| 57 | + $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
| 58 | + /** |
|
| 59 | + * Called just after trashing (soft delete) or restoring a trashed item. |
|
| 60 | + * |
|
| 61 | + * @param EE_Base_Class $model_object that was just trashed or restored. |
|
| 62 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
| 63 | + * @param bool|int $result |
|
| 64 | + */ |
|
| 65 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
| 66 | + return $result; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Performs a restoration (un-deletes) this object |
|
| 73 | - * |
|
| 74 | - * @return bool|int |
|
| 75 | - */ |
|
| 76 | - public function restore() |
|
| 77 | - { |
|
| 78 | - return $this->delete_or_restore(false); |
|
| 79 | - } |
|
| 71 | + /** |
|
| 72 | + * Performs a restoration (un-deletes) this object |
|
| 73 | + * |
|
| 74 | + * @return bool|int |
|
| 75 | + */ |
|
| 76 | + public function restore() |
|
| 77 | + { |
|
| 78 | + return $this->delete_or_restore(false); |
|
| 79 | + } |
|
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | /** |