@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\shortcodes\espresso_events; |
| 3 | 3 | |
| 4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 5 | - exit( 'No direct script access allowed' ); |
|
| 4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 5 | + exit('No direct script access allowed'); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
@@ -42,16 +42,16 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @param array $args |
| 44 | 44 | */ |
| 45 | - public function __construct( $args = array() ) { |
|
| 45 | + public function __construct($args = array()) { |
|
| 46 | 46 | // incoming args could be a mix of WP query args + EE shortcode args |
| 47 | - foreach ( $args as $key => $value ) { |
|
| 48 | - $property = '_' . $key; |
|
| 47 | + foreach ($args as $key => $value) { |
|
| 48 | + $property = '_'.$key; |
|
| 49 | 49 | // if the arg is a property of this class, then it's an EE shortcode arg |
| 50 | - if ( property_exists( $this, $property ) ) { |
|
| 50 | + if (property_exists($this, $property)) { |
|
| 51 | 51 | // set the property value |
| 52 | 52 | $this->{$property} = $value; |
| 53 | 53 | // then remove it from the array of args that will later be passed to WP_Query() |
| 54 | - unset( $args[ $key ] ); |
|
| 54 | + unset($args[$key]); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | //add query filters |
@@ -67,20 +67,20 @@ discard block |
||
| 67 | 67 | // first off, let's remove any filters from previous queries |
| 68 | 68 | remove_filter( |
| 69 | 69 | 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
| 70 | - array( $this, 'event_list_title' ) |
|
| 70 | + array($this, 'event_list_title') |
|
| 71 | 71 | ); |
| 72 | - remove_all_filters( 'FHEE__content_espresso_events__event_class' ); |
|
| 72 | + remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
| 73 | 73 | // Event List Title ? |
| 74 | 74 | add_filter( |
| 75 | 75 | 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
| 76 | - array( $this, 'event_list_title' ), |
|
| 76 | + array($this, 'event_list_title'), |
|
| 77 | 77 | 10, |
| 78 | 78 | 1 |
| 79 | 79 | ); |
| 80 | 80 | // add the css class |
| 81 | - add_filter( 'FHEE__content_espresso_events__event_class', array( $this, 'event_list_css' ), 10, 1 ); |
|
| 81 | + add_filter('FHEE__content_espresso_events__event_class', array($this, 'event_list_css'), 10, 1); |
|
| 82 | 82 | // the current "page" we are viewing |
| 83 | - $paged = max( 1, get_query_var( 'paged' ) ); |
|
| 83 | + $paged = max(1, get_query_var('paged')); |
|
| 84 | 84 | // Force these args |
| 85 | 85 | $args = array_merge( |
| 86 | 86 | $args, |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | 'update_post_term_cache' => false, |
| 91 | 91 | 'update_post_meta_cache' => false, |
| 92 | 92 | 'paged' => $paged, |
| 93 | - 'offset' => ( $paged - 1 ) * $this->_limit |
|
| 93 | + 'offset' => ($paged - 1) * $this->_limit |
|
| 94 | 94 | ) |
| 95 | 95 | ); |
| 96 | 96 | // run the query |
| 97 | - parent::__construct( $args ); |
|
| 97 | + parent::__construct($args); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | * @param string $event_list_title |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | - public function event_list_title( $event_list_title = '' ) { |
|
| 110 | - if ( ! empty( $this->_title ) ) { |
|
| 109 | + public function event_list_title($event_list_title = '') { |
|
| 110 | + if ( ! empty($this->_title)) { |
|
| 111 | 111 | return $this->_title; |
| 112 | 112 | } |
| 113 | 113 | return $event_list_title; |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | * @param string $event_list_css |
| 123 | 123 | * @return array |
| 124 | 124 | */ |
| 125 | - public function event_list_css( $event_list_css = '' ) { |
|
| 126 | - $event_list_css .= ! empty( $event_list_css ) ? ' ' : ''; |
|
| 127 | - $event_list_css .= ! empty( $this->_css_class ) ? $this->_css_class : ''; |
|
| 128 | - $event_list_css .= ! empty( $event_list_css ) ? ' ' : ''; |
|
| 129 | - $event_list_css .= ! empty( $this->_category_slug ) ? $this->_category_slug : ''; |
|
| 125 | + public function event_list_css($event_list_css = '') { |
|
| 126 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
| 127 | + $event_list_css .= ! empty($this->_css_class) ? $this->_css_class : ''; |
|
| 128 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
| 129 | + $event_list_css .= ! empty($this->_category_slug) ? $this->_category_slug : ''; |
|
| 130 | 130 | return $event_list_css; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -21,9 +21,12 @@ |
||
| 21 | 21 | <title><?php echo $title; ?></title> |
| 22 | 22 | <?php if ( $enqueue_wp_assets ) : ?> |
| 23 | 23 | <?php wp_head(); ?> |
| 24 | -<?php else : ?> |
|
| 24 | +<?php else { |
|
| 25 | + : ?> |
|
| 25 | 26 | <?php foreach ( $css as $url ) : ?> |
| 26 | - <link rel="stylesheet" type="text/css" href="<?php echo $url;?>"> |
|
| 27 | + <link rel="stylesheet" type="text/css" href="<?php echo $url; |
|
| 28 | +} |
|
| 29 | +?>"> |
|
| 27 | 30 | <?php endforeach; ?> |
| 28 | 31 | <script type="text/javascript"> |
| 29 | 32 | <?php echo $eei18n; ?> |
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | <html> |
| 20 | 20 | <head> |
| 21 | 21 | <title><?php echo $title; ?></title> |
| 22 | -<?php if ( $enqueue_wp_assets ) : ?> |
|
| 22 | +<?php if ($enqueue_wp_assets) : ?> |
|
| 23 | 23 | <?php wp_head(); ?> |
| 24 | 24 | <?php else : ?> |
| 25 | - <?php foreach ( $css as $url ) : ?> |
|
| 26 | - <link rel="stylesheet" type="text/css" href="<?php echo $url;?>"> |
|
| 25 | + <?php foreach ($css as $url) : ?> |
|
| 26 | + <link rel="stylesheet" type="text/css" href="<?php echo $url; ?>"> |
|
| 27 | 27 | <?php endforeach; ?> |
| 28 | 28 | <script type="text/javascript"> |
| 29 | 29 | <?php echo $eei18n; ?> |
| 30 | 30 | </script> |
| 31 | - <?php foreach ( $header_js as $url ) : ?> |
|
| 31 | + <?php foreach ($header_js as $url) : ?> |
|
| 32 | 32 | <script type="text/javascript" src="<?php echo $url; ?>"></script> |
| 33 | 33 | <?php endforeach; ?> |
| 34 | 34 | <?php endif; ?> |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | <div style="padding: 1em;"> |
| 39 | 39 | <?php echo $content; ?> |
| 40 | 40 | </div> |
| 41 | - <?php foreach ( $footer_js as $url ) : ?> |
|
| 41 | + <?php foreach ($footer_js as $url) : ?> |
|
| 42 | 42 | <script type="text/javascript" src="<?php echo $url; ?>"></script> |
| 43 | 43 | <?php endforeach; ?> |
| 44 | -<?php if ( $enqueue_wp_assets ) : ?> |
|
| 44 | +<?php if ($enqueue_wp_assets) : ?> |
|
| 45 | 45 | <?php wp_footer(); ?> |
| 46 | 46 | <?php endif; ?> |
| 47 | 47 | </body> |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @param string $word |
| 55 | - * @return mixed |
|
| 55 | + * @return string |
|
| 56 | 56 | */ |
| 57 | 57 | public static function singularize_and_upper( $word ) { |
| 58 | 58 | return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) ); |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | - * @param $string |
|
| 382 | + * @param string $string |
|
| 383 | 383 | * @return string |
| 384 | 384 | */ |
| 385 | 385 | public static function add_indefinite_article($string) { |
@@ -35,357 +35,357 @@ |
||
| 35 | 35 | * @version $Revision 0.1 $ |
| 36 | 36 | */ |
| 37 | 37 | class EEH_Inflector{ |
| 38 | - // ------ CLASS METHODS ------ // |
|
| 39 | - // ---- Public methods ---- // |
|
| 40 | - // {{{ pluralize() |
|
| 38 | + // ------ CLASS METHODS ------ // |
|
| 39 | + // ---- Public methods ---- // |
|
| 40 | + // {{{ pluralize() |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Just calls self::pluralize and strtolower on $word and returns it |
| 44 | 44 | * @param string $word |
| 45 | 45 | * @return string |
| 46 | 46 | */ |
| 47 | - public static function pluralize_and_lower( $word ){ |
|
| 47 | + public static function pluralize_and_lower( $word ){ |
|
| 48 | 48 | return strtolower( self::pluralize( $word ) ); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @param string $word |
|
| 55 | - * @return mixed |
|
| 56 | - */ |
|
| 57 | - public static function singularize_and_upper( $word ) { |
|
| 53 | + /** |
|
| 54 | + * @param string $word |
|
| 55 | + * @return mixed |
|
| 56 | + */ |
|
| 57 | + public static function singularize_and_upper( $word ) { |
|
| 58 | 58 | return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) ); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Pluralizes English nouns. |
|
| 65 | - * |
|
| 66 | - * @access public |
|
| 67 | - * @static |
|
| 68 | - * @param string $word English noun to pluralize |
|
| 69 | - * @return string Plural noun |
|
| 70 | - */ |
|
| 71 | - public static function pluralize($word){ |
|
| 72 | - $plural = array( |
|
| 73 | - '/(quiz)$/i' => '\1zes', |
|
| 74 | - '/^(ox)$/i' => '\1en', |
|
| 75 | - '/([m|l])ouse$/i' => '\1ice', |
|
| 76 | - '/(matr|vert|ind)ix|ex$/i' => '\1ices', |
|
| 77 | - '/(x|ch|ss|sh)$/i' => '\1es', |
|
| 78 | - '/([^aeiouy]|qu)ies$/i' => '\1y', |
|
| 79 | - '/([^aeiouy]|qu)y$/i' => '\1ies', |
|
| 80 | - '/(hive)$/i' => '\1s', |
|
| 81 | - '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', |
|
| 82 | - '/sis$/i' => 'ses', |
|
| 83 | - '/([ti])um$/i' => '\1a', |
|
| 84 | - '/(buffal|tomat)o$/i' => '\1oes', |
|
| 85 | - '/(bu)s$/i' => '\1ses', |
|
| 86 | - '/(alias|status)/i' => '\1es', |
|
| 87 | - '/(octop|vir)us$/i' => '\1i', |
|
| 88 | - '/(ax|test)is$/i' => '\1es', |
|
| 89 | - '/s$/i' => 's', |
|
| 90 | - '/$/' => 's'); |
|
| 91 | - |
|
| 92 | - $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); |
|
| 93 | - |
|
| 94 | - $irregular = array( |
|
| 95 | - 'person' => 'people', |
|
| 96 | - 'man' => 'men', |
|
| 97 | - 'child' => 'children', |
|
| 98 | - 'sex' => 'sexes', |
|
| 99 | - 'move' => 'moves'); |
|
| 100 | - |
|
| 101 | - $lowercased_word = strtolower($word); |
|
| 102 | - |
|
| 103 | - foreach($uncountable as $_uncountable){ |
|
| 104 | - if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter |
|
| 63 | + /** |
|
| 64 | + * Pluralizes English nouns. |
|
| 65 | + * |
|
| 66 | + * @access public |
|
| 67 | + * @static |
|
| 68 | + * @param string $word English noun to pluralize |
|
| 69 | + * @return string Plural noun |
|
| 70 | + */ |
|
| 71 | + public static function pluralize($word){ |
|
| 72 | + $plural = array( |
|
| 73 | + '/(quiz)$/i' => '\1zes', |
|
| 74 | + '/^(ox)$/i' => '\1en', |
|
| 75 | + '/([m|l])ouse$/i' => '\1ice', |
|
| 76 | + '/(matr|vert|ind)ix|ex$/i' => '\1ices', |
|
| 77 | + '/(x|ch|ss|sh)$/i' => '\1es', |
|
| 78 | + '/([^aeiouy]|qu)ies$/i' => '\1y', |
|
| 79 | + '/([^aeiouy]|qu)y$/i' => '\1ies', |
|
| 80 | + '/(hive)$/i' => '\1s', |
|
| 81 | + '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', |
|
| 82 | + '/sis$/i' => 'ses', |
|
| 83 | + '/([ti])um$/i' => '\1a', |
|
| 84 | + '/(buffal|tomat)o$/i' => '\1oes', |
|
| 85 | + '/(bu)s$/i' => '\1ses', |
|
| 86 | + '/(alias|status)/i' => '\1es', |
|
| 87 | + '/(octop|vir)us$/i' => '\1i', |
|
| 88 | + '/(ax|test)is$/i' => '\1es', |
|
| 89 | + '/s$/i' => 's', |
|
| 90 | + '/$/' => 's'); |
|
| 91 | + |
|
| 92 | + $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); |
|
| 93 | + |
|
| 94 | + $irregular = array( |
|
| 95 | + 'person' => 'people', |
|
| 96 | + 'man' => 'men', |
|
| 97 | + 'child' => 'children', |
|
| 98 | + 'sex' => 'sexes', |
|
| 99 | + 'move' => 'moves'); |
|
| 100 | + |
|
| 101 | + $lowercased_word = strtolower($word); |
|
| 102 | + |
|
| 103 | + foreach($uncountable as $_uncountable){ |
|
| 104 | + if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter |
|
| 105 | 105 | ! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){ |
| 106 | - return $word; |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - foreach($irregular as $_plural => $_singular){ |
|
| 111 | - if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){ |
|
| 112 | - return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word); |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - foreach($plural as $rule => $replacement){ |
|
| 117 | - if(preg_match($rule, $word)){ |
|
| 118 | - return preg_replace($rule, $replacement, $word); |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - return false; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // }}} |
|
| 125 | - // {{{ singularize() |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Singularizes English nouns. |
|
| 129 | - * |
|
| 130 | - * @access public |
|
| 131 | - * @static |
|
| 132 | - * @param string $word English noun to singularize |
|
| 133 | - * @return string Singular noun. |
|
| 134 | - */ |
|
| 135 | - public static function singularize($word){ |
|
| 136 | - $singular = array( |
|
| 137 | - '/(quiz)zes$/i' => '\1', |
|
| 138 | - '/(matr)ices$/i' => '\1ix', |
|
| 139 | - '/(vert|ind)ices$/i' => '\1ex', |
|
| 140 | - '/^(ox)en/i' => '\1', |
|
| 141 | - '/(alias|status)es$/i' => '\1', |
|
| 142 | - '/([octop|vir])i$/i' => '\1us', |
|
| 143 | - '/(cris|ax|test)es$/i' => '\1is', |
|
| 144 | - '/(shoe)s$/i' => '\1', |
|
| 145 | - '/(o)es$/i' => '\1', |
|
| 146 | - '/(bus)es$/i' => '\1', |
|
| 147 | - '/([m|l])ice$/i' => '\1ouse', |
|
| 148 | - '/(x|ch|ss|sh)es$/i' => '\1', |
|
| 149 | - '/(m)ovies$/i' => '\1ovie', |
|
| 150 | - '/(s)eries$/i' => '\1eries', |
|
| 151 | - '/([^aeiouy]|qu)ies$/i' => '\1y', |
|
| 152 | - '/([lr])ves$/i' => '\1f', |
|
| 153 | - '/(tive)s$/i' => '\1', |
|
| 154 | - '/(hive)s$/i' => '\1', |
|
| 155 | - '/([^f])ves$/i' => '\1fe', |
|
| 156 | - '/(^analy)ses$/i' => '\1sis', |
|
| 157 | - '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis', |
|
| 158 | - '/([ti])a$/i' => '\1um', |
|
| 159 | - '/(n)ews$/i' => '\1ews', |
|
| 160 | - '/s$/i' => '', |
|
| 161 | - ); |
|
| 162 | - |
|
| 163 | - $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); |
|
| 164 | - |
|
| 165 | - $irregular = array( |
|
| 166 | - 'person' => 'people', |
|
| 167 | - 'man' => 'men', |
|
| 168 | - 'child' => 'children', |
|
| 169 | - 'sex' => 'sexes', |
|
| 170 | - 'move' => 'moves'); |
|
| 171 | - |
|
| 172 | - $lowercased_word = strtolower($word); |
|
| 173 | - foreach($uncountable as $_uncountable){ |
|
| 174 | - if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){ |
|
| 175 | - return $word; |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - foreach($irregular as $_plural => $_singular){ |
|
| 180 | - if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){ |
|
| 181 | - return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word); |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - foreach($singular as $rule => $replacement){ |
|
| 186 | - if(preg_match($rule, $word)){ |
|
| 187 | - return preg_replace($rule, $replacement, $word); |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - return $word; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - // }}} |
|
| 195 | - // {{{ titleize() |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * Converts an underscored or CamelCase word into a English |
|
| 199 | - * sentence. |
|
| 200 | - * |
|
| 201 | - * The titleize static function converts text like "WelcomePage", |
|
| 202 | - * "welcome_page" or "welcome page" to this "Welcome |
|
| 203 | - * Page". |
|
| 204 | - * If second parameter is set to 'first' it will only |
|
| 205 | - * capitalize the first character of the title. |
|
| 206 | - * |
|
| 207 | - * @access public |
|
| 208 | - * @static |
|
| 209 | - * @param string $word Word to format as tile |
|
| 210 | - * @param string $uppercase If set to 'first' it will only uppercase the |
|
| 211 | - * first character. Otherwise it will uppercase all |
|
| 212 | - * the words in the title. |
|
| 213 | - * @return string Text formatted as title |
|
| 214 | - */ |
|
| 215 | - public static function titleize($word, $uppercase = ''){ |
|
| 216 | - $uppercase = $uppercase === 'first' ? 'ucfirst' : 'ucwords'; |
|
| 217 | - return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word))); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - // }}} |
|
| 221 | - // {{{ camelize() |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * Returns given word as CamelCased |
|
| 225 | - * |
|
| 226 | - * Converts a word like "send_email" to "SendEmail". It |
|
| 227 | - * will remove non alphanumeric character from the word, so |
|
| 228 | - * "who's online" will be converted to "WhoSOnline" |
|
| 229 | - * |
|
| 230 | - * @access public |
|
| 231 | - * @static |
|
| 232 | - * @see variablize |
|
| 233 | - * @param string $word Word to convert to camel case |
|
| 234 | - * @return string UpperCamelCasedWord |
|
| 235 | - */ |
|
| 236 | - public static function camelize($word){ |
|
| 237 | - return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word))); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // }}} |
|
| 241 | - // {{{ underscore() |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Converts a word "into_it_s_underscored_version" |
|
| 245 | - * |
|
| 246 | - * Convert any "CamelCased" or "ordinary Word" into an |
|
| 247 | - * "underscored_word". |
|
| 248 | - * |
|
| 249 | - * This can be really useful for creating friendly URLs. |
|
| 250 | - * |
|
| 251 | - * @access public |
|
| 252 | - * @static |
|
| 253 | - * @param string $word Word to underscore |
|
| 254 | - * @return string Underscored word |
|
| 255 | - */ |
|
| 256 | - public static function underscore($word){ |
|
| 257 | - return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word)))); |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - // }}} |
|
| 261 | - // {{{ humanize() |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * Returns a human-readable string from $word |
|
| 265 | - * |
|
| 266 | - * Returns a human-readable string from $word, by replacing |
|
| 267 | - * underscores with a space, and by upper-casing the initial |
|
| 268 | - * character by default. |
|
| 269 | - * |
|
| 270 | - * If you need to uppercase all the words you just have to |
|
| 271 | - * pass 'all' as a second parameter. |
|
| 272 | - * |
|
| 273 | - * @access public |
|
| 274 | - * @static |
|
| 275 | - * @param string $word String to "humanize" |
|
| 276 | - * @param string $uppercase If set to 'all' it will uppercase all the words |
|
| 277 | - * instead of just the first one. |
|
| 278 | - * @return string Human-readable word |
|
| 279 | - */ |
|
| 280 | - public static function humanize($word, $uppercase = ''){ |
|
| 106 | + return $word; |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + foreach($irregular as $_plural => $_singular){ |
|
| 111 | + if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){ |
|
| 112 | + return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word); |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + foreach($plural as $rule => $replacement){ |
|
| 117 | + if(preg_match($rule, $word)){ |
|
| 118 | + return preg_replace($rule, $replacement, $word); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + return false; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // }}} |
|
| 125 | + // {{{ singularize() |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Singularizes English nouns. |
|
| 129 | + * |
|
| 130 | + * @access public |
|
| 131 | + * @static |
|
| 132 | + * @param string $word English noun to singularize |
|
| 133 | + * @return string Singular noun. |
|
| 134 | + */ |
|
| 135 | + public static function singularize($word){ |
|
| 136 | + $singular = array( |
|
| 137 | + '/(quiz)zes$/i' => '\1', |
|
| 138 | + '/(matr)ices$/i' => '\1ix', |
|
| 139 | + '/(vert|ind)ices$/i' => '\1ex', |
|
| 140 | + '/^(ox)en/i' => '\1', |
|
| 141 | + '/(alias|status)es$/i' => '\1', |
|
| 142 | + '/([octop|vir])i$/i' => '\1us', |
|
| 143 | + '/(cris|ax|test)es$/i' => '\1is', |
|
| 144 | + '/(shoe)s$/i' => '\1', |
|
| 145 | + '/(o)es$/i' => '\1', |
|
| 146 | + '/(bus)es$/i' => '\1', |
|
| 147 | + '/([m|l])ice$/i' => '\1ouse', |
|
| 148 | + '/(x|ch|ss|sh)es$/i' => '\1', |
|
| 149 | + '/(m)ovies$/i' => '\1ovie', |
|
| 150 | + '/(s)eries$/i' => '\1eries', |
|
| 151 | + '/([^aeiouy]|qu)ies$/i' => '\1y', |
|
| 152 | + '/([lr])ves$/i' => '\1f', |
|
| 153 | + '/(tive)s$/i' => '\1', |
|
| 154 | + '/(hive)s$/i' => '\1', |
|
| 155 | + '/([^f])ves$/i' => '\1fe', |
|
| 156 | + '/(^analy)ses$/i' => '\1sis', |
|
| 157 | + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis', |
|
| 158 | + '/([ti])a$/i' => '\1um', |
|
| 159 | + '/(n)ews$/i' => '\1ews', |
|
| 160 | + '/s$/i' => '', |
|
| 161 | + ); |
|
| 162 | + |
|
| 163 | + $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); |
|
| 164 | + |
|
| 165 | + $irregular = array( |
|
| 166 | + 'person' => 'people', |
|
| 167 | + 'man' => 'men', |
|
| 168 | + 'child' => 'children', |
|
| 169 | + 'sex' => 'sexes', |
|
| 170 | + 'move' => 'moves'); |
|
| 171 | + |
|
| 172 | + $lowercased_word = strtolower($word); |
|
| 173 | + foreach($uncountable as $_uncountable){ |
|
| 174 | + if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){ |
|
| 175 | + return $word; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + foreach($irregular as $_plural => $_singular){ |
|
| 180 | + if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){ |
|
| 181 | + return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word); |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + foreach($singular as $rule => $replacement){ |
|
| 186 | + if(preg_match($rule, $word)){ |
|
| 187 | + return preg_replace($rule, $replacement, $word); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + return $word; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + // }}} |
|
| 195 | + // {{{ titleize() |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * Converts an underscored or CamelCase word into a English |
|
| 199 | + * sentence. |
|
| 200 | + * |
|
| 201 | + * The titleize static function converts text like "WelcomePage", |
|
| 202 | + * "welcome_page" or "welcome page" to this "Welcome |
|
| 203 | + * Page". |
|
| 204 | + * If second parameter is set to 'first' it will only |
|
| 205 | + * capitalize the first character of the title. |
|
| 206 | + * |
|
| 207 | + * @access public |
|
| 208 | + * @static |
|
| 209 | + * @param string $word Word to format as tile |
|
| 210 | + * @param string $uppercase If set to 'first' it will only uppercase the |
|
| 211 | + * first character. Otherwise it will uppercase all |
|
| 212 | + * the words in the title. |
|
| 213 | + * @return string Text formatted as title |
|
| 214 | + */ |
|
| 215 | + public static function titleize($word, $uppercase = ''){ |
|
| 216 | + $uppercase = $uppercase === 'first' ? 'ucfirst' : 'ucwords'; |
|
| 217 | + return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word))); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + // }}} |
|
| 221 | + // {{{ camelize() |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * Returns given word as CamelCased |
|
| 225 | + * |
|
| 226 | + * Converts a word like "send_email" to "SendEmail". It |
|
| 227 | + * will remove non alphanumeric character from the word, so |
|
| 228 | + * "who's online" will be converted to "WhoSOnline" |
|
| 229 | + * |
|
| 230 | + * @access public |
|
| 231 | + * @static |
|
| 232 | + * @see variablize |
|
| 233 | + * @param string $word Word to convert to camel case |
|
| 234 | + * @return string UpperCamelCasedWord |
|
| 235 | + */ |
|
| 236 | + public static function camelize($word){ |
|
| 237 | + return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word))); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // }}} |
|
| 241 | + // {{{ underscore() |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Converts a word "into_it_s_underscored_version" |
|
| 245 | + * |
|
| 246 | + * Convert any "CamelCased" or "ordinary Word" into an |
|
| 247 | + * "underscored_word". |
|
| 248 | + * |
|
| 249 | + * This can be really useful for creating friendly URLs. |
|
| 250 | + * |
|
| 251 | + * @access public |
|
| 252 | + * @static |
|
| 253 | + * @param string $word Word to underscore |
|
| 254 | + * @return string Underscored word |
|
| 255 | + */ |
|
| 256 | + public static function underscore($word){ |
|
| 257 | + return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word)))); |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + // }}} |
|
| 261 | + // {{{ humanize() |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * Returns a human-readable string from $word |
|
| 265 | + * |
|
| 266 | + * Returns a human-readable string from $word, by replacing |
|
| 267 | + * underscores with a space, and by upper-casing the initial |
|
| 268 | + * character by default. |
|
| 269 | + * |
|
| 270 | + * If you need to uppercase all the words you just have to |
|
| 271 | + * pass 'all' as a second parameter. |
|
| 272 | + * |
|
| 273 | + * @access public |
|
| 274 | + * @static |
|
| 275 | + * @param string $word String to "humanize" |
|
| 276 | + * @param string $uppercase If set to 'all' it will uppercase all the words |
|
| 277 | + * instead of just the first one. |
|
| 278 | + * @return string Human-readable word |
|
| 279 | + */ |
|
| 280 | + public static function humanize($word, $uppercase = ''){ |
|
| 281 | 281 | //make special exceptions for acronyms |
| 282 | 282 | $word = str_replace('wp_', 'WP_', $word ); |
| 283 | - $uppercase = $uppercase === 'all' ? 'ucwords' : 'ucfirst'; |
|
| 284 | - return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word))); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - // }}} |
|
| 288 | - // {{{ variablize() |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * Same as camelize but first char is underscored |
|
| 292 | - * |
|
| 293 | - * Converts a word like "send_email" to "sendEmail". It |
|
| 294 | - * will remove non alphanumeric character from the word, so |
|
| 295 | - * "who's online" will be converted to "whoSOnline" |
|
| 296 | - * |
|
| 297 | - * @access public |
|
| 298 | - * @static |
|
| 299 | - * @see camelize |
|
| 300 | - * @param string $word Word to lowerCamelCase |
|
| 301 | - * @return string Returns a lowerCamelCasedWord |
|
| 302 | - */ |
|
| 303 | - public static function variablize($word){ |
|
| 304 | - $word = EEH_Inflector::camelize($word); |
|
| 305 | - return strtolower($word[0]) . substr($word, 1); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - // }}} |
|
| 309 | - // {{{ tableize() |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * Converts a class name to its table name according to rails |
|
| 313 | - * naming conventions. |
|
| 314 | - * |
|
| 315 | - * Converts "Person" to "people" |
|
| 316 | - * |
|
| 317 | - * @access public |
|
| 318 | - * @static |
|
| 319 | - * @see classify |
|
| 320 | - * @param string $class_name Class name for getting related table_name. |
|
| 321 | - * @return string plural_table_name |
|
| 322 | - */ |
|
| 323 | - public static function tableize($class_name){ |
|
| 324 | - return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name)); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - // }}} |
|
| 328 | - // {{{ classify() |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * Converts a table name to its class name according to rails |
|
| 332 | - * naming conventions. |
|
| 333 | - * |
|
| 334 | - * Converts "people" to "Person" |
|
| 335 | - * |
|
| 336 | - * @access public |
|
| 337 | - * @static |
|
| 338 | - * @see tableize |
|
| 339 | - * @param string $table_name Table name for getting related ClassName. |
|
| 340 | - * @return string SingularClassName |
|
| 341 | - */ |
|
| 342 | - public static function classify($table_name){ |
|
| 343 | - return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name)); |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - // }}} |
|
| 347 | - // {{{ ordinalize() |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * Converts number to its ordinal English form. |
|
| 351 | - * |
|
| 352 | - * This method converts 13 to 13th, 2 to 2nd ... |
|
| 353 | - * |
|
| 354 | - * @access public |
|
| 355 | - * @static |
|
| 356 | - * @param integer $number Number to get its ordinal value |
|
| 357 | - * @return string Ordinal representation of given string. |
|
| 358 | - */ |
|
| 359 | - public static function ordinalize($number){ |
|
| 360 | - if(in_array(($number % 100), range(11, 13))){ |
|
| 361 | - return $number . 'th'; |
|
| 362 | - }else{ |
|
| 363 | - switch(($number % 10)){ |
|
| 364 | - case 1: |
|
| 365 | - return $number . 'st'; |
|
| 366 | - break; |
|
| 367 | - case 2: |
|
| 368 | - return $number . 'nd'; |
|
| 369 | - break; |
|
| 370 | - case 3: |
|
| 371 | - return $number . 'rd'; |
|
| 372 | - default: |
|
| 373 | - return $number . 'th'; |
|
| 374 | - break; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * @param $string |
|
| 383 | - * @return string |
|
| 384 | - */ |
|
| 385 | - public static function add_indefinite_article($string) { |
|
| 386 | - if (strtolower($string) === 'null') { |
|
| 387 | - return $string; |
|
| 388 | - } |
|
| 389 | - return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string; |
|
| 390 | - } |
|
| 283 | + $uppercase = $uppercase === 'all' ? 'ucwords' : 'ucfirst'; |
|
| 284 | + return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word))); |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + // }}} |
|
| 288 | + // {{{ variablize() |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * Same as camelize but first char is underscored |
|
| 292 | + * |
|
| 293 | + * Converts a word like "send_email" to "sendEmail". It |
|
| 294 | + * will remove non alphanumeric character from the word, so |
|
| 295 | + * "who's online" will be converted to "whoSOnline" |
|
| 296 | + * |
|
| 297 | + * @access public |
|
| 298 | + * @static |
|
| 299 | + * @see camelize |
|
| 300 | + * @param string $word Word to lowerCamelCase |
|
| 301 | + * @return string Returns a lowerCamelCasedWord |
|
| 302 | + */ |
|
| 303 | + public static function variablize($word){ |
|
| 304 | + $word = EEH_Inflector::camelize($word); |
|
| 305 | + return strtolower($word[0]) . substr($word, 1); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + // }}} |
|
| 309 | + // {{{ tableize() |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * Converts a class name to its table name according to rails |
|
| 313 | + * naming conventions. |
|
| 314 | + * |
|
| 315 | + * Converts "Person" to "people" |
|
| 316 | + * |
|
| 317 | + * @access public |
|
| 318 | + * @static |
|
| 319 | + * @see classify |
|
| 320 | + * @param string $class_name Class name for getting related table_name. |
|
| 321 | + * @return string plural_table_name |
|
| 322 | + */ |
|
| 323 | + public static function tableize($class_name){ |
|
| 324 | + return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name)); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + // }}} |
|
| 328 | + // {{{ classify() |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * Converts a table name to its class name according to rails |
|
| 332 | + * naming conventions. |
|
| 333 | + * |
|
| 334 | + * Converts "people" to "Person" |
|
| 335 | + * |
|
| 336 | + * @access public |
|
| 337 | + * @static |
|
| 338 | + * @see tableize |
|
| 339 | + * @param string $table_name Table name for getting related ClassName. |
|
| 340 | + * @return string SingularClassName |
|
| 341 | + */ |
|
| 342 | + public static function classify($table_name){ |
|
| 343 | + return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name)); |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + // }}} |
|
| 347 | + // {{{ ordinalize() |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * Converts number to its ordinal English form. |
|
| 351 | + * |
|
| 352 | + * This method converts 13 to 13th, 2 to 2nd ... |
|
| 353 | + * |
|
| 354 | + * @access public |
|
| 355 | + * @static |
|
| 356 | + * @param integer $number Number to get its ordinal value |
|
| 357 | + * @return string Ordinal representation of given string. |
|
| 358 | + */ |
|
| 359 | + public static function ordinalize($number){ |
|
| 360 | + if(in_array(($number % 100), range(11, 13))){ |
|
| 361 | + return $number . 'th'; |
|
| 362 | + }else{ |
|
| 363 | + switch(($number % 10)){ |
|
| 364 | + case 1: |
|
| 365 | + return $number . 'st'; |
|
| 366 | + break; |
|
| 367 | + case 2: |
|
| 368 | + return $number . 'nd'; |
|
| 369 | + break; |
|
| 370 | + case 3: |
|
| 371 | + return $number . 'rd'; |
|
| 372 | + default: |
|
| 373 | + return $number . 'th'; |
|
| 374 | + break; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * @param $string |
|
| 383 | + * @return string |
|
| 384 | + */ |
|
| 385 | + public static function add_indefinite_article($string) { |
|
| 386 | + if (strtolower($string) === 'null') { |
|
| 387 | + return $string; |
|
| 388 | + } |
|
| 389 | + return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string; |
|
| 390 | + } |
|
| 391 | 391 | } |
| 392 | 392 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | // +----------------------------------------------------------------------+ |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @since 0.1 |
| 35 | 35 | * @version $Revision 0.1 $ |
| 36 | 36 | */ |
| 37 | -class EEH_Inflector{ |
|
| 37 | +class EEH_Inflector { |
|
| 38 | 38 | // ------ CLASS METHODS ------ // |
| 39 | 39 | // ---- Public methods ---- // |
| 40 | 40 | // {{{ pluralize() |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | * @param string $word |
| 45 | 45 | * @return string |
| 46 | 46 | */ |
| 47 | - public static function pluralize_and_lower( $word ){ |
|
| 48 | - return strtolower( self::pluralize( $word ) ); |
|
| 47 | + public static function pluralize_and_lower($word) { |
|
| 48 | + return strtolower(self::pluralize($word)); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | * @param string $word |
| 55 | 55 | * @return mixed |
| 56 | 56 | */ |
| 57 | - public static function singularize_and_upper( $word ) { |
|
| 58 | - return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) ); |
|
| 57 | + public static function singularize_and_upper($word) { |
|
| 58 | + return str_replace(' ', '_', self::humanize(self::singularize($word), 'all')); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param string $word English noun to pluralize |
| 69 | 69 | * @return string Plural noun |
| 70 | 70 | */ |
| 71 | - public static function pluralize($word){ |
|
| 71 | + public static function pluralize($word) { |
|
| 72 | 72 | $plural = array( |
| 73 | 73 | '/(quiz)$/i' => '\1zes', |
| 74 | 74 | '/^(ox)$/i' => '\1en', |
@@ -100,21 +100,21 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $lowercased_word = strtolower($word); |
| 102 | 102 | |
| 103 | - foreach($uncountable as $_uncountable){ |
|
| 104 | - if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter |
|
| 105 | - ! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){ |
|
| 103 | + foreach ($uncountable as $_uncountable) { |
|
| 104 | + if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter |
|
| 105 | + ! ctype_alpha($lowercased_word[strlen($lowercased_word) - strlen($_uncountable)])) { |
|
| 106 | 106 | return $word; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - foreach($irregular as $_plural => $_singular){ |
|
| 111 | - if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){ |
|
| 112 | - return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word); |
|
| 110 | + foreach ($irregular as $_plural => $_singular) { |
|
| 111 | + if (preg_match('/('.$_plural.')$/i', $word, $arr)) { |
|
| 112 | + return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - foreach($plural as $rule => $replacement){ |
|
| 117 | - if(preg_match($rule, $word)){ |
|
| 116 | + foreach ($plural as $rule => $replacement) { |
|
| 117 | + if (preg_match($rule, $word)) { |
|
| 118 | 118 | return preg_replace($rule, $replacement, $word); |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param string $word English noun to singularize |
| 133 | 133 | * @return string Singular noun. |
| 134 | 134 | */ |
| 135 | - public static function singularize($word){ |
|
| 135 | + public static function singularize($word) { |
|
| 136 | 136 | $singular = array( |
| 137 | 137 | '/(quiz)zes$/i' => '\1', |
| 138 | 138 | '/(matr)ices$/i' => '\1ix', |
@@ -170,20 +170,20 @@ discard block |
||
| 170 | 170 | 'move' => 'moves'); |
| 171 | 171 | |
| 172 | 172 | $lowercased_word = strtolower($word); |
| 173 | - foreach($uncountable as $_uncountable){ |
|
| 174 | - if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){ |
|
| 173 | + foreach ($uncountable as $_uncountable) { |
|
| 174 | + if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable) { |
|
| 175 | 175 | return $word; |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - foreach($irregular as $_plural => $_singular){ |
|
| 180 | - if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){ |
|
| 181 | - return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word); |
|
| 179 | + foreach ($irregular as $_plural => $_singular) { |
|
| 180 | + if (preg_match('/('.$_singular.')$/i', $word, $arr)) { |
|
| 181 | + return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - foreach($singular as $rule => $replacement){ |
|
| 186 | - if(preg_match($rule, $word)){ |
|
| 185 | + foreach ($singular as $rule => $replacement) { |
|
| 186 | + if (preg_match($rule, $word)) { |
|
| 187 | 187 | return preg_replace($rule, $replacement, $word); |
| 188 | 188 | } |
| 189 | 189 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * the words in the title. |
| 213 | 213 | * @return string Text formatted as title |
| 214 | 214 | */ |
| 215 | - public static function titleize($word, $uppercase = ''){ |
|
| 215 | + public static function titleize($word, $uppercase = '') { |
|
| 216 | 216 | $uppercase = $uppercase === 'first' ? 'ucfirst' : 'ucwords'; |
| 217 | 217 | return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word))); |
| 218 | 218 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @param string $word Word to convert to camel case |
| 234 | 234 | * @return string UpperCamelCasedWord |
| 235 | 235 | */ |
| 236 | - public static function camelize($word){ |
|
| 236 | + public static function camelize($word) { |
|
| 237 | 237 | return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word))); |
| 238 | 238 | } |
| 239 | 239 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @param string $word Word to underscore |
| 254 | 254 | * @return string Underscored word |
| 255 | 255 | */ |
| 256 | - public static function underscore($word){ |
|
| 256 | + public static function underscore($word) { |
|
| 257 | 257 | return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word)))); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -277,9 +277,9 @@ discard block |
||
| 277 | 277 | * instead of just the first one. |
| 278 | 278 | * @return string Human-readable word |
| 279 | 279 | */ |
| 280 | - public static function humanize($word, $uppercase = ''){ |
|
| 280 | + public static function humanize($word, $uppercase = '') { |
|
| 281 | 281 | //make special exceptions for acronyms |
| 282 | - $word = str_replace('wp_', 'WP_', $word ); |
|
| 282 | + $word = str_replace('wp_', 'WP_', $word); |
|
| 283 | 283 | $uppercase = $uppercase === 'all' ? 'ucwords' : 'ucfirst'; |
| 284 | 284 | return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word))); |
| 285 | 285 | } |
@@ -300,9 +300,9 @@ discard block |
||
| 300 | 300 | * @param string $word Word to lowerCamelCase |
| 301 | 301 | * @return string Returns a lowerCamelCasedWord |
| 302 | 302 | */ |
| 303 | - public static function variablize($word){ |
|
| 303 | + public static function variablize($word) { |
|
| 304 | 304 | $word = EEH_Inflector::camelize($word); |
| 305 | - return strtolower($word[0]) . substr($word, 1); |
|
| 305 | + return strtolower($word[0]).substr($word, 1); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | // }}} |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * @param string $class_name Class name for getting related table_name. |
| 321 | 321 | * @return string plural_table_name |
| 322 | 322 | */ |
| 323 | - public static function tableize($class_name){ |
|
| 323 | + public static function tableize($class_name) { |
|
| 324 | 324 | return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name)); |
| 325 | 325 | } |
| 326 | 326 | |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | * @param string $table_name Table name for getting related ClassName. |
| 340 | 340 | * @return string SingularClassName |
| 341 | 341 | */ |
| 342 | - public static function classify($table_name){ |
|
| 342 | + public static function classify($table_name) { |
|
| 343 | 343 | return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name)); |
| 344 | 344 | } |
| 345 | 345 | |
@@ -356,21 +356,21 @@ discard block |
||
| 356 | 356 | * @param integer $number Number to get its ordinal value |
| 357 | 357 | * @return string Ordinal representation of given string. |
| 358 | 358 | */ |
| 359 | - public static function ordinalize($number){ |
|
| 360 | - if(in_array(($number % 100), range(11, 13))){ |
|
| 361 | - return $number . 'th'; |
|
| 362 | - }else{ |
|
| 363 | - switch(($number % 10)){ |
|
| 359 | + public static function ordinalize($number) { |
|
| 360 | + if (in_array(($number % 100), range(11, 13))) { |
|
| 361 | + return $number.'th'; |
|
| 362 | + } else { |
|
| 363 | + switch (($number % 10)) { |
|
| 364 | 364 | case 1: |
| 365 | - return $number . 'st'; |
|
| 365 | + return $number.'st'; |
|
| 366 | 366 | break; |
| 367 | 367 | case 2: |
| 368 | - return $number . 'nd'; |
|
| 368 | + return $number.'nd'; |
|
| 369 | 369 | break; |
| 370 | 370 | case 3: |
| 371 | - return $number . 'rd'; |
|
| 371 | + return $number.'rd'; |
|
| 372 | 372 | default: |
| 373 | - return $number . 'th'; |
|
| 373 | + return $number.'th'; |
|
| 374 | 374 | break; |
| 375 | 375 | } |
| 376 | 376 | } |
@@ -386,6 +386,6 @@ discard block |
||
| 386 | 386 | if (strtolower($string) === 'null') { |
| 387 | 387 | return $string; |
| 388 | 388 | } |
| 389 | - return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string; |
|
| 389 | + return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ').$string; |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | \ No newline at end of file |
@@ -359,7 +359,7 @@ |
||
| 359 | 359 | public static function ordinalize($number){ |
| 360 | 360 | if(in_array(($number % 100), range(11, 13))){ |
| 361 | 361 | return $number . 'th'; |
| 362 | - }else{ |
|
| 362 | + } else{ |
|
| 363 | 363 | switch(($number % 10)){ |
| 364 | 364 | case 1: |
| 365 | 365 | return $number . 'st'; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 4 | - exit( 'No direct script access allowed' ); |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | /** |
| 7 | 7 | * |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function __construct() { |
| 54 | 54 | // deprecated functions |
| 55 | - espresso_load_required( 'EventEspresso\core\Factory', EE_CORE . 'Factory.php' ); |
|
| 55 | + espresso_load_required('EventEspresso\core\Factory', EE_CORE.'Factory.php'); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
@@ -68,16 +68,16 @@ discard block |
||
| 68 | 68 | * @param EE_Response $response |
| 69 | 69 | * @return EE_Response |
| 70 | 70 | */ |
| 71 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
| 71 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
| 72 | 72 | $this->request = $request; |
| 73 | 73 | $this->response = $response; |
| 74 | 74 | // info about how to load classes required by other classes |
| 75 | 75 | $this->dependency_map = $this->_load_dependency_map(); |
| 76 | 76 | // central repository for classes |
| 77 | 77 | $this->registry = $this->_load_registry(); |
| 78 | - do_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading' ); |
|
| 78 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
| 79 | 79 | // PSR4 Autoloaders |
| 80 | - $this->registry->load_core( 'EE_Psr4AutoloaderInit' ); |
|
| 80 | + $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
| 81 | 81 | // build DI container |
| 82 | 82 | $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
| 83 | 83 | $OpenCoffeeShop->addRecipes(); |
@@ -87,20 +87,20 @@ discard block |
||
| 87 | 87 | 'CommandBusInterface', |
| 88 | 88 | array( |
| 89 | 89 | null, |
| 90 | - $this->registry->create( 'CapChecker' ) |
|
| 90 | + $this->registry->create('CapChecker') |
|
| 91 | 91 | ), |
| 92 | 92 | true |
| 93 | 93 | ); |
| 94 | 94 | // workarounds for PHP < 5.3 |
| 95 | 95 | $this->_load_class_tools(); |
| 96 | 96 | // load interfaces |
| 97 | - espresso_load_required( 'EEI_Payment_Method_Interfaces', EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php' ); |
|
| 97 | + espresso_load_required('EEI_Payment_Method_Interfaces', EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php'); |
|
| 98 | 98 | // deprecated functions |
| 99 | - espresso_load_required( 'EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php' ); |
|
| 99 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
| 100 | 100 | // WP cron jobs |
| 101 | - $this->registry->load_core( 'Cron_Tasks' ); |
|
| 102 | - $this->registry->load_core( 'EE_Request_Handler' ); |
|
| 103 | - $this->registry->load_core( 'EE_System' ); |
|
| 101 | + $this->registry->load_core('Cron_Tasks'); |
|
| 102 | + $this->registry->load_core('EE_Request_Handler'); |
|
| 103 | + $this->registry->load_core('EE_System'); |
|
| 104 | 104 | |
| 105 | 105 | return $this->response; |
| 106 | 106 | } |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | * @throws \EE_Error |
| 131 | 131 | */ |
| 132 | 132 | public function dependency_map() { |
| 133 | - if ( ! $this->dependency_map instanceof EE_Dependency_Map ) { |
|
| 133 | + if ( ! $this->dependency_map instanceof EE_Dependency_Map) { |
|
| 134 | 134 | throw new EE_Error( |
| 135 | 135 | sprintf( |
| 136 | - __( 'Invalid EE_Dependency_Map: "%1$s"', 'event_espresso' ), |
|
| 137 | - print_r( $this->dependency_map, true ) |
|
| 136 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
| 137 | + print_r($this->dependency_map, true) |
|
| 138 | 138 | ) |
| 139 | 139 | ); |
| 140 | 140 | } |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | * @throws \EE_Error |
| 149 | 149 | */ |
| 150 | 150 | public function registry() { |
| 151 | - if ( ! $this->registry instanceof EE_Registry ) { |
|
| 151 | + if ( ! $this->registry instanceof EE_Registry) { |
|
| 152 | 152 | throw new EE_Error( |
| 153 | 153 | sprintf( |
| 154 | - __( 'Invalid EE_Registry: "%1$s"', 'event_espresso' ), |
|
| 155 | - print_r( $this->registry, true ) |
|
| 154 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
| 155 | + print_r($this->registry, true) |
|
| 156 | 156 | ) |
| 157 | 157 | ); |
| 158 | 158 | } |
@@ -168,15 +168,15 @@ discard block |
||
| 168 | 168 | * @return EE_Dependency_Map |
| 169 | 169 | */ |
| 170 | 170 | private function _load_dependency_map() { |
| 171 | - if ( ! is_readable( EE_CORE . 'EE_Dependency_Map.core.php' ) ) { |
|
| 171 | + if ( ! is_readable(EE_CORE.'EE_Dependency_Map.core.php')) { |
|
| 172 | 172 | EE_Error::add_error( |
| 173 | - __( 'The EE_Dependency_Map core class could not be loaded.', 'event_espresso' ), |
|
| 173 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
| 174 | 174 | __FILE__, __FUNCTION__, __LINE__ |
| 175 | 175 | ); |
| 176 | - wp_die( EE_Error::get_notices() ); |
|
| 176 | + wp_die(EE_Error::get_notices()); |
|
| 177 | 177 | } |
| 178 | - require_once( EE_CORE . 'EE_Dependency_Map.core.php' ); |
|
| 179 | - return EE_Dependency_Map::instance( $this->request, $this->response ); |
|
| 178 | + require_once(EE_CORE.'EE_Dependency_Map.core.php'); |
|
| 179 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | * @return EE_Registry |
| 189 | 189 | */ |
| 190 | 190 | private function _load_registry() { |
| 191 | - if ( ! is_readable( EE_CORE . 'EE_Registry.core.php' )) { |
|
| 191 | + if ( ! is_readable(EE_CORE.'EE_Registry.core.php')) { |
|
| 192 | 192 | EE_Error::add_error( |
| 193 | - __( 'The EE_Registry core class could not be loaded.', 'event_espresso' ), |
|
| 193 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
| 194 | 194 | __FILE__, __FUNCTION__, __LINE__ |
| 195 | 195 | ); |
| 196 | - wp_die( EE_Error::get_notices() ); |
|
| 196 | + wp_die(EE_Error::get_notices()); |
|
| 197 | 197 | } |
| 198 | - require_once( EE_CORE . 'EE_Registry.core.php' ); |
|
| 199 | - return EE_Registry::instance( $this->dependency_map ); |
|
| 198 | + require_once(EE_CORE.'EE_Registry.core.php'); |
|
| 199 | + return EE_Registry::instance($this->dependency_map); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | |
@@ -207,13 +207,13 @@ discard block |
||
| 207 | 207 | * @return void |
| 208 | 208 | */ |
| 209 | 209 | private function _load_class_tools() { |
| 210 | - if ( ! is_readable( EE_HELPERS . 'EEH_Class_Tools.helper.php' )) { |
|
| 210 | + if ( ! is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) { |
|
| 211 | 211 | EE_Error::add_error( |
| 212 | - __( 'The EEH_Class_Tools helper could not be loaded.', 'event_espresso' ), |
|
| 212 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
| 213 | 213 | __FILE__, __FUNCTION__, __LINE__ |
| 214 | 214 | ); |
| 215 | 215 | } |
| 216 | - require_once( EE_HELPERS . 'EEH_Class_Tools.helper.php' ); |
|
| 216 | + require_once(EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | * @param \EE_Request $request |
| 228 | 228 | * @param \EE_Response $response |
| 229 | 229 | */ |
| 230 | - public function handle_response( EE_Request $request, EE_Response $response ) { |
|
| 230 | + public function handle_response(EE_Request $request, EE_Response $response) { |
|
| 231 | 231 | //\EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
| 232 | 232 | //EEH_Debug_Tools::printr( $request, '$request', __FILE__, __LINE__ ); |
| 233 | 233 | //EEH_Debug_Tools::printr( $response, '$response', __FILE__, __LINE__ ); |
| 234 | 234 | //die(); |
| 235 | - if ( $response->plugin_deactivated() ) { |
|
| 236 | - espresso_deactivate_plugin( EE_PLUGIN_BASENAME ); |
|
| 235 | + if ($response->plugin_deactivated()) { |
|
| 236 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -102,8 +102,8 @@ |
||
| 102 | 102 | // use_captcha ? |
| 103 | 103 | if ( |
| 104 | 104 | EE_Registry::instance()->CFG->registration->use_captcha |
| 105 | - && EE_Registry::instance()->REQ->get( 'step', '' ) !== '' |
|
| 106 | - && ! ( |
|
| 105 | + && EE_Registry::instance()->REQ->get( 'step', '' ) !== '' |
|
| 106 | + && ! ( |
|
| 107 | 107 | EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options' |
| 108 | 108 | && (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true |
| 109 | 109 | ) |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return EED_Recaptcha |
| 44 | 44 | */ |
| 45 | 45 | public static function instance() { |
| 46 | - return parent::get_instance( __CLASS__ ); |
|
| 46 | + return parent::get_instance(__CLASS__); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
@@ -59,32 +59,32 @@ discard block |
||
| 59 | 59 | if ( |
| 60 | 60 | EE_Registry::instance()->CFG->registration->use_captcha |
| 61 | 61 | && ! ( |
| 62 | - EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options' |
|
| 63 | - && (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true |
|
| 62 | + EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
| 63 | + && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
| 64 | 64 | ) |
| 65 | 65 | ) { |
| 66 | 66 | EED_Recaptcha::set_definitions(); |
| 67 | 67 | EED_Recaptcha::enqueue_styles_and_scripts(); |
| 68 | - add_action( 'wp', array( 'EED_Recaptcha', 'set_late_hooks' ), 1, 0 ); |
|
| 68 | + add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0); |
|
| 69 | 69 | add_action( |
| 70 | 70 | 'AHEE__before_spco_whats_next_buttons', |
| 71 | - array( 'EED_Recaptcha', 'display_recaptcha' ), 10, 0 |
|
| 71 | + array('EED_Recaptcha', 'display_recaptcha'), 10, 0 |
|
| 72 | 72 | ); |
| 73 | 73 | add_filter( |
| 74 | 74 | 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
| 75 | - array( 'EED_Recaptcha', 'not_a_robot' ), 10 |
|
| 75 | + array('EED_Recaptcha', 'not_a_robot'), 10 |
|
| 76 | 76 | ); |
| 77 | 77 | add_filter( |
| 78 | 78 | 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
| 79 | - array( 'EED_Recaptcha', 'not_a_robot' ), 10 |
|
| 79 | + array('EED_Recaptcha', 'not_a_robot'), 10 |
|
| 80 | 80 | ); |
| 81 | 81 | add_filter( |
| 82 | 82 | 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
| 83 | - array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1 |
|
| 83 | + array('EED_Recaptcha', 'recaptcha_response'), 10, 1 |
|
| 84 | 84 | ); |
| 85 | 85 | add_filter( |
| 86 | 86 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
| 87 | - array( 'EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method' ), 10, 1 |
|
| 87 | + array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method'), 10, 1 |
|
| 88 | 88 | ); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -102,20 +102,20 @@ discard block |
||
| 102 | 102 | // use_captcha ? |
| 103 | 103 | if ( |
| 104 | 104 | EE_Registry::instance()->CFG->registration->use_captcha |
| 105 | - && EE_Registry::instance()->REQ->get( 'step', '' ) !== '' |
|
| 105 | + && EE_Registry::instance()->REQ->get('step', '') !== '' |
|
| 106 | 106 | && ! ( |
| 107 | - EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options' |
|
| 108 | - && (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true |
|
| 107 | + EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
| 108 | + && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
| 109 | 109 | ) |
| 110 | 110 | ) { |
| 111 | 111 | EED_Recaptcha::enqueue_styles_and_scripts(); |
| 112 | - add_filter( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', array( 'EED_Recaptcha', 'not_a_robot' ), 10 ); |
|
| 113 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', array( 'EED_Recaptcha', 'not_a_robot' ), 10 ); |
|
| 114 | - add_filter( 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1 ); |
|
| 112 | + add_filter('FHEE__EED_Single_Page_Checkout__init___continue_reg', array('EED_Recaptcha', 'not_a_robot'), 10); |
|
| 113 | + add_filter('FHEE__EE_SPCO_Reg_Step__set_completed___completed', array('EED_Recaptcha', 'not_a_robot'), 10); |
|
| 114 | + add_filter('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', array('EED_Recaptcha', 'recaptcha_response'), 10, 1); |
|
| 115 | 115 | } |
| 116 | 116 | // admin settings |
| 117 | - add_action( 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', array( 'EED_Recaptcha', 'admin_settings' ), 10, 1 ); |
|
| 118 | - add_filter( 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', array( 'EED_Recaptcha', 'update_admin_settings' ), 10, 1 ); |
|
| 117 | + add_action('AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', array('EED_Recaptcha', 'admin_settings'), 10, 1); |
|
| 118 | + add_filter('FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', array('EED_Recaptcha', 'update_admin_settings'), 10, 1); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | * @return void |
| 128 | 128 | */ |
| 129 | 129 | public static function set_definitions() { |
| 130 | - if ( is_user_logged_in() ) { |
|
| 130 | + if (is_user_logged_in()) { |
|
| 131 | 131 | EED_Recaptcha::$_not_a_robot = true; |
| 132 | 132 | } |
| 133 | - define( 'RECAPTCHA_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
| 134 | - define( 'RECAPTCHA_BASE_URL', plugin_dir_url( __FILE__ )); |
|
| 133 | + define('RECAPTCHA_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
| 134 | + define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public static function set_late_hooks() { |
| 146 | 146 | add_filter( |
| 147 | 147 | 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
| 148 | - array( 'EED_Recaptcha', 'not_a_robot' ) |
|
| 148 | + array('EED_Recaptcha', 'not_a_robot') |
|
| 149 | 149 | ); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | * @return void |
| 159 | 159 | */ |
| 160 | 160 | public static function enqueue_styles_and_scripts() { |
| 161 | - wp_register_script( 'espresso_recaptcha', RECAPTCHA_BASE_URL . 'scripts' . DS . 'espresso_recaptcha.js', array( 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 162 | - wp_register_script( 'google_recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . EE_Registry::instance()->CFG->registration->recaptcha_language, array( 'espresso_recaptcha' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 163 | - EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
| 164 | - EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
| 165 | - EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( 'Please complete the anti-spam test before proceeding.', 'event_espresso' ); |
|
| 161 | + wp_register_script('espresso_recaptcha', RECAPTCHA_BASE_URL.'scripts'.DS.'espresso_recaptcha.js', array('single_page_checkout'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 162 | + wp_register_script('google_recaptcha', 'https://www.google.com/recaptcha/api.js?hl='.EE_Registry::instance()->CFG->registration->recaptcha_language, array('espresso_recaptcha'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 163 | + EE_Registry::$i18n_js_strings['no_SPCO_error'] = __('It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
| 164 | + EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __('There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
| 165 | + EE_Registry::$i18n_js_strings['recaptcha_fail'] = __('Please complete the anti-spam test before proceeding.', 'event_espresso'); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @access public |
| 174 | 174 | * @param \WP $WP |
| 175 | 175 | */ |
| 176 | - public function run( $WP ) { |
|
| 176 | + public function run($WP) { |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
@@ -183,8 +183,7 @@ discard block |
||
| 183 | 183 | * @return boolean |
| 184 | 184 | */ |
| 185 | 185 | public static function not_a_robot() { |
| 186 | - $not_a_robot = is_bool( EED_Recaptcha::$_not_a_robot ) ? EED_Recaptcha::$_not_a_robot : |
|
| 187 | - EED_Recaptcha::recaptcha_passed(); |
|
| 186 | + $not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot) ? EED_Recaptcha::$_not_a_robot : EED_Recaptcha::recaptcha_passed(); |
|
| 188 | 187 | return $not_a_robot; |
| 189 | 188 | } |
| 190 | 189 | |
@@ -200,22 +199,22 @@ discard block |
||
| 200 | 199 | */ |
| 201 | 200 | public static function display_recaptcha() { |
| 202 | 201 | // logged in means you have already passed a turing test of sorts |
| 203 | - if ( is_user_logged_in() ) { |
|
| 202 | + if (is_user_logged_in()) { |
|
| 204 | 203 | return; |
| 205 | 204 | } |
| 206 | 205 | // don't display if not using recaptcha or user is logged in |
| 207 | - if ( EE_Registry::instance()->CFG->registration->use_captcha ) { |
|
| 206 | + if (EE_Registry::instance()->CFG->registration->use_captcha) { |
|
| 208 | 207 | // only display if they have NOT passed the test yet |
| 209 | - if ( ! EED_Recaptcha::$_not_a_robot ) { |
|
| 208 | + if ( ! EED_Recaptcha::$_not_a_robot) { |
|
| 210 | 209 | EEH_Template::display_template( |
| 211 | - RECAPTCHA_BASE_PATH . DS . 'templates' . DS . 'recaptcha.template.php', |
|
| 210 | + RECAPTCHA_BASE_PATH.DS.'templates'.DS.'recaptcha.template.php', |
|
| 212 | 211 | array( |
| 213 | 212 | 'recaptcha_publickey' => EE_Registry::instance()->CFG->registration->recaptcha_publickey, |
| 214 | 213 | 'recaptcha_theme' => EE_Registry::instance()->CFG->registration->recaptcha_theme, |
| 215 | 214 | 'recaptcha_type' => EE_Registry::instance()->CFG->registration->recaptcha_type |
| 216 | 215 | ) |
| 217 | 216 | ); |
| 218 | - wp_enqueue_script( 'google_recaptcha' ); |
|
| 217 | + wp_enqueue_script('google_recaptcha'); |
|
| 219 | 218 | } |
| 220 | 219 | } |
| 221 | 220 | } |
@@ -246,17 +245,17 @@ discard block |
||
| 246 | 245 | */ |
| 247 | 246 | public static function recaptcha_passed() { |
| 248 | 247 | // logged in means you have already passed a turing test of sorts |
| 249 | - if ( is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha() ) { |
|
| 248 | + if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) { |
|
| 250 | 249 | return TRUE; |
| 251 | 250 | } |
| 252 | 251 | // was test already passed? |
| 253 | - $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data( 'recaptcha_passed' ); |
|
| 254 | - $recaptcha_passed = filter_var( $recaptcha_passed, FILTER_VALIDATE_BOOLEAN ); |
|
| 252 | + $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed'); |
|
| 253 | + $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
|
| 255 | 254 | // verify recaptcha |
| 256 | 255 | EED_Recaptcha::_get_recaptcha_response(); |
| 257 | - if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response ) { |
|
| 256 | + if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
| 258 | 257 | $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
| 259 | - EE_Registry::instance()->SSN->set_session_data( array( 'recaptcha_passed' => $recaptcha_passed )); |
|
| 258 | + EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
|
| 260 | 259 | } |
| 261 | 260 | EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
| 262 | 261 | return $recaptcha_passed; |
@@ -271,8 +270,8 @@ discard block |
||
| 271 | 270 | * @param array $recaptcha_response |
| 272 | 271 | * @return boolean |
| 273 | 272 | */ |
| 274 | - public static function recaptcha_response( $recaptcha_response = array() ) { |
|
| 275 | - if ( EED_Recaptcha::_bypass_recaptcha() ) { |
|
| 273 | + public static function recaptcha_response($recaptcha_response = array()) { |
|
| 274 | + if (EED_Recaptcha::_bypass_recaptcha()) { |
|
| 276 | 275 | $recaptcha_response['bypass_recaptcha'] = TRUE; |
| 277 | 276 | $recaptcha_response['recaptcha_passed'] = TRUE; |
| 278 | 277 | } else { |
@@ -292,16 +291,16 @@ discard block |
||
| 292 | 291 | */ |
| 293 | 292 | private static function _bypass_recaptcha() { |
| 294 | 293 | // an array of key value pairs that must match exactly with the incoming request, in order to bypass recaptcha for the current request ONLY |
| 295 | - $bypass_request_params_array = apply_filters( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array() ); |
|
| 294 | + $bypass_request_params_array = apply_filters('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array()); |
|
| 296 | 295 | // does $bypass_request_params_array have any values ? |
| 297 | - if ( empty( $bypass_request_params_array )) { |
|
| 296 | + if (empty($bypass_request_params_array)) { |
|
| 298 | 297 | return FALSE; |
| 299 | 298 | } |
| 300 | 299 | // initially set bypass to TRUE |
| 301 | 300 | $bypass_recaptcha = TRUE; |
| 302 | - foreach ( $bypass_request_params_array as $key => $value ) { |
|
| 301 | + foreach ($bypass_request_params_array as $key => $value) { |
|
| 303 | 302 | // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, otherwise carry over it's value. This way, one missed setting results in no bypass |
| 304 | - $bypass_recaptcha = isset( $_REQUEST[ $key ] ) && $_REQUEST[ $key ] === $value ? $bypass_recaptcha : FALSE; |
|
| 303 | + $bypass_recaptcha = isset($_REQUEST[$key]) && $_REQUEST[$key] === $value ? $bypass_recaptcha : FALSE; |
|
| 305 | 304 | } |
| 306 | 305 | return $bypass_recaptcha; |
| 307 | 306 | } |
@@ -316,7 +315,7 @@ discard block |
||
| 316 | 315 | * @return boolean |
| 317 | 316 | */ |
| 318 | 317 | private static function _get_recaptcha_response() { |
| 319 | - EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get( 'g-recaptcha-response', false ); |
|
| 318 | + EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get('g-recaptcha-response', false); |
|
| 320 | 319 | } |
| 321 | 320 | |
| 322 | 321 | |
@@ -330,26 +329,26 @@ discard block |
||
| 330 | 329 | */ |
| 331 | 330 | private static function _process_recaptcha_response() { |
| 332 | 331 | // verify library is loaded |
| 333 | - if ( ! class_exists( '\\ReCaptcha\\ReCaptcha' )) { |
|
| 334 | - require_once( RECAPTCHA_BASE_PATH . DS . 'autoload.php' ); |
|
| 332 | + if ( ! class_exists('\\ReCaptcha\\ReCaptcha')) { |
|
| 333 | + require_once(RECAPTCHA_BASE_PATH.DS.'autoload.php'); |
|
| 335 | 334 | } |
| 336 | 335 | // The response from reCAPTCHA |
| 337 | 336 | EED_Recaptcha::_get_recaptcha_response(); |
| 338 | 337 | $recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
| 339 | 338 | // Was there a reCAPTCHA response? |
| 340 | - if ( $recaptcha_response ) { |
|
| 339 | + if ($recaptcha_response) { |
|
| 341 | 340 | // if allow_url_fopen is Off, then set a different request method |
| 342 | - $request_method = ! ini_get( 'allow_url_fopen' ) ? new \ReCaptcha\RequestMethod\SocketPost() : null; |
|
| 341 | + $request_method = ! ini_get('allow_url_fopen') ? new \ReCaptcha\RequestMethod\SocketPost() : null; |
|
| 343 | 342 | $recaptcha = new \ReCaptcha\ReCaptcha( |
| 344 | 343 | EE_Registry::instance()->CFG->registration->recaptcha_privatekey, |
| 345 | 344 | $request_method |
| 346 | 345 | ); |
| 347 | 346 | $recaptcha_response = $recaptcha->verify( |
| 348 | 347 | EED_Recaptcha::$_recaptcha_response, |
| 349 | - $_SERVER[ 'REMOTE_ADDR' ] |
|
| 348 | + $_SERVER['REMOTE_ADDR'] |
|
| 350 | 349 | ); |
| 351 | 350 | } |
| 352 | - if ( $recaptcha_response instanceof \ReCaptcha\Response && $recaptcha_response->isSuccess() ) { |
|
| 351 | + if ($recaptcha_response instanceof \ReCaptcha\Response && $recaptcha_response->isSuccess()) { |
|
| 353 | 352 | return TRUE; |
| 354 | 353 | } |
| 355 | 354 | // sorry... it appears you can't don't know what soup or hamburgers are !!! |
@@ -393,12 +392,12 @@ discard block |
||
| 393 | 392 | 'subsections' => apply_filters( |
| 394 | 393 | 'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections', |
| 395 | 394 | array( |
| 396 | - 'main_settings_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Anti-spam Settings', 'event_espresso' ) . EEH_Template::get_help_tab_link( 'recaptcha_info' ))), |
|
| 395 | + 'main_settings_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(__('reCAPTCHA Anti-spam Settings', 'event_espresso').EEH_Template::get_help_tab_link('recaptcha_info'))), |
|
| 397 | 396 | 'main_settings' => EED_Recaptcha::_recaptcha_main_settings(), |
| 398 | - 'appearance_settings_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Appearance', 'event_espresso' ) )), |
|
| 397 | + 'appearance_settings_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(__('reCAPTCHA Appearance', 'event_espresso'))), |
|
| 399 | 398 | 'appearance_settings' => EED_Recaptcha::_recaptcha_appearance_settings(), |
| 400 | 399 | // 'recaptcha_example' => new EE_Form_Section_HTML( EED_Recaptcha::display_recaptcha() ), |
| 401 | - 'required_fields_note' => new EE_Form_Section_HTML( EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )) |
|
| 400 | + 'required_fields_note' => new EE_Form_Section_HTML(EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')) |
|
| 402 | 401 | ) |
| 403 | 402 | ) |
| 404 | 403 | ) |
@@ -425,28 +424,28 @@ discard block |
||
| 425 | 424 | array( |
| 426 | 425 | 'use_captcha' => new EE_Yes_No_Input( |
| 427 | 426 | array( |
| 428 | - 'html_label_text' => __( 'Use reCAPTCHA', 'event_espresso' ), |
|
| 427 | + 'html_label_text' => __('Use reCAPTCHA', 'event_espresso'), |
|
| 429 | 428 | 'html_help_text' => sprintf( |
| 430 | - __( 'reCAPTCHA is a free service that protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', 'event_espresso' ), |
|
| 429 | + __('reCAPTCHA is a free service that protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', 'event_espresso'), |
|
| 431 | 430 | '<a href="https://www.google.com/recaptcha/intro/index.html">', |
| 432 | 431 | '</a>' |
| 433 | 432 | ), |
| 434 | - 'default' => isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE, |
|
| 433 | + 'default' => isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE, |
|
| 435 | 434 | 'display_html_label_text' => FALSE |
| 436 | 435 | ) |
| 437 | 436 | ), |
| 438 | 437 | 'recaptcha_publickey' => new EE_Text_Input( |
| 439 | 438 | array( |
| 440 | - 'html_label_text' => __( 'Site Key', 'event_espresso' ), |
|
| 441 | - 'html_help_text' => __( 'The site key is used to display the widget on your site.', 'event_espresso' ), |
|
| 442 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : '' |
|
| 439 | + 'html_label_text' => __('Site Key', 'event_espresso'), |
|
| 440 | + 'html_help_text' => __('The site key is used to display the widget on your site.', 'event_espresso'), |
|
| 441 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : '' |
|
| 443 | 442 | ) |
| 444 | 443 | ), |
| 445 | 444 | 'recaptcha_privatekey' => new EE_Text_Input( |
| 446 | 445 | array( |
| 447 | - 'html_label_text' => __( 'Secret Key', 'event_espresso' ), |
|
| 448 | - 'html_help_text' => __( 'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', 'event_espresso' ), |
|
| 449 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : '' |
|
| 446 | + 'html_label_text' => __('Secret Key', 'event_espresso'), |
|
| 447 | + 'html_help_text' => __('The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', 'event_espresso'), |
|
| 448 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : '' |
|
| 450 | 449 | ) |
| 451 | 450 | ) |
| 452 | 451 | ) |
@@ -478,81 +477,81 @@ discard block |
||
| 478 | 477 | array( |
| 479 | 478 | 'recaptcha_theme' => new EE_Radio_Button_Input( |
| 480 | 479 | array( |
| 481 | - 'light' => __( 'Light', 'event_espresso' ), |
|
| 482 | - 'dark' => __( 'Dark', 'event_espresso' ) |
|
| 480 | + 'light' => __('Light', 'event_espresso'), |
|
| 481 | + 'dark' => __('Dark', 'event_espresso') |
|
| 483 | 482 | ), |
| 484 | 483 | array( |
| 485 | - 'html_label_text' => __( 'Theme', 'event_espresso' ), |
|
| 486 | - 'html_help_text' => __( 'The color theme of the widget.', 'event_espresso' ), |
|
| 487 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->recaptcha_theme : 'light', |
|
| 484 | + 'html_label_text' => __('Theme', 'event_espresso'), |
|
| 485 | + 'html_help_text' => __('The color theme of the widget.', 'event_espresso'), |
|
| 486 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->recaptcha_theme : 'light', |
|
| 488 | 487 | 'display_html_label_text' => FALSE |
| 489 | 488 | ) |
| 490 | 489 | ), |
| 491 | 490 | 'recaptcha_type' => new EE_Radio_Button_Input( |
| 492 | 491 | array( |
| 493 | - 'image' => __( 'Image', 'event_espresso' ), |
|
| 494 | - 'audio' => __( 'Audio', 'event_espresso' ) |
|
| 492 | + 'image' => __('Image', 'event_espresso'), |
|
| 493 | + 'audio' => __('Audio', 'event_espresso') |
|
| 495 | 494 | ), |
| 496 | 495 | array( |
| 497 | - 'html_label_text' => __( 'Type', 'event_espresso' ), |
|
| 498 | - 'html_help_text' => __( 'The type of CAPTCHA to serve.', 'event_espresso' ), |
|
| 499 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_type ) ? EE_Registry::instance()->CFG->registration->recaptcha_type : 'image', |
|
| 496 | + 'html_label_text' => __('Type', 'event_espresso'), |
|
| 497 | + 'html_help_text' => __('The type of CAPTCHA to serve.', 'event_espresso'), |
|
| 498 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_type) ? EE_Registry::instance()->CFG->registration->recaptcha_type : 'image', |
|
| 500 | 499 | 'display_html_label_text' =>FALSE |
| 501 | 500 | ) |
| 502 | 501 | ), |
| 503 | 502 | 'recaptcha_language' => new EE_Select_Input( |
| 504 | 503 | array( |
| 505 | - 'ar' => __( 'Arabic', 'event_espresso' ), |
|
| 506 | - 'bg' => __( 'Bulgarian', 'event_espresso' ), |
|
| 507 | - 'ca' => __( 'Catalan', 'event_espresso' ), |
|
| 508 | - 'zh-CN' => __( 'Chinese (Simplified)', 'event_espresso' ), |
|
| 509 | - 'zh-TW' => __( 'Chinese (Traditional) ', 'event_espresso' ), |
|
| 510 | - 'hr' => __( 'Croatian', 'event_espresso' ), |
|
| 511 | - 'cs' => __( 'Czech', 'event_espresso' ), |
|
| 512 | - 'da' => __( 'Danish', 'event_espresso' ), |
|
| 513 | - 'nl' => __( 'Dutch', 'event_espresso' ), |
|
| 514 | - 'en-GB' => __( 'English (UK)', 'event_espresso' ), |
|
| 515 | - 'en' => __( 'English (US)', 'event_espresso' ), |
|
| 516 | - 'fil' => __( 'Filipino', 'event_espresso' ), |
|
| 517 | - 'fi' => __( 'Finnish', 'event_espresso' ), |
|
| 518 | - 'fr' => __( 'French', 'event_espresso' ), |
|
| 519 | - 'fr-CA' => __( 'French (Canadian)', 'event_espresso' ), |
|
| 520 | - 'de' => __( 'German', 'event_espresso' ), |
|
| 521 | - 'de-AT' => __( 'German (Austria)', 'event_espresso' ), |
|
| 522 | - 'de-CH' => __( 'German (Switzerland)', 'event_espresso' ), |
|
| 523 | - 'el' => __( 'Greek', 'event_espresso' ), |
|
| 524 | - 'iw' => __( 'Hebrew', 'event_espresso' ), |
|
| 525 | - 'hi' => __( 'Hindi', 'event_espresso' ), |
|
| 526 | - 'hu' => __( 'Hungarian', 'event_espresso' ), |
|
| 527 | - 'id' => __( 'Indonesian', 'event_espresso' ), |
|
| 528 | - 'it' => __( 'Italian', 'event_espresso' ), |
|
| 529 | - 'ja' => __( 'Japanese', 'event_espresso' ), |
|
| 530 | - 'ko' => __( 'Korean', 'event_espresso' ), |
|
| 531 | - 'lv' => __( 'Latvian', 'event_espresso' ), |
|
| 532 | - 'lt' => __( 'Lithuanian', 'event_espresso' ), |
|
| 533 | - 'no' => __( 'Norwegian', 'event_espresso' ), |
|
| 534 | - 'fa' => __( 'Persian', 'event_espresso' ), |
|
| 535 | - 'pl' => __( 'Polish', 'event_espresso' ), |
|
| 536 | - 'pt' => __( 'Portuguese', 'event_espresso' ), |
|
| 537 | - 'pt-BR' => __( 'Portuguese (Brazil)', 'event_espresso' ), |
|
| 538 | - 'pt-PT' => __( 'Portuguese (Portugal)', 'event_espresso' ), |
|
| 539 | - 'ro' => __( 'Romanian', 'event_espresso' ), |
|
| 540 | - 'ru' => __( 'Russian', 'event_espresso' ), |
|
| 541 | - 'sr' => __( 'Serbian', 'event_espresso' ), |
|
| 542 | - 'sk' => __( 'Slovak', 'event_espresso' ), |
|
| 543 | - 'sl' => __( 'Slovenian', 'event_espresso' ), |
|
| 544 | - 'es' => __( 'Spanish', 'event_espresso' ), |
|
| 545 | - 'es-419' => __( 'Spanish (Latin America)', 'event_espresso' ), |
|
| 546 | - 'sv' => __( 'Swedish', 'event_espresso' ), |
|
| 547 | - 'th' => __( 'Thai', 'event_espresso' ), |
|
| 548 | - 'tr' => __( 'Turkish', 'event_espresso' ), |
|
| 549 | - 'uk' => __( 'Ukrainian', 'event_espresso' ), |
|
| 550 | - 'vi' => __( 'Vietnamese', 'event_espresso') |
|
| 504 | + 'ar' => __('Arabic', 'event_espresso'), |
|
| 505 | + 'bg' => __('Bulgarian', 'event_espresso'), |
|
| 506 | + 'ca' => __('Catalan', 'event_espresso'), |
|
| 507 | + 'zh-CN' => __('Chinese (Simplified)', 'event_espresso'), |
|
| 508 | + 'zh-TW' => __('Chinese (Traditional) ', 'event_espresso'), |
|
| 509 | + 'hr' => __('Croatian', 'event_espresso'), |
|
| 510 | + 'cs' => __('Czech', 'event_espresso'), |
|
| 511 | + 'da' => __('Danish', 'event_espresso'), |
|
| 512 | + 'nl' => __('Dutch', 'event_espresso'), |
|
| 513 | + 'en-GB' => __('English (UK)', 'event_espresso'), |
|
| 514 | + 'en' => __('English (US)', 'event_espresso'), |
|
| 515 | + 'fil' => __('Filipino', 'event_espresso'), |
|
| 516 | + 'fi' => __('Finnish', 'event_espresso'), |
|
| 517 | + 'fr' => __('French', 'event_espresso'), |
|
| 518 | + 'fr-CA' => __('French (Canadian)', 'event_espresso'), |
|
| 519 | + 'de' => __('German', 'event_espresso'), |
|
| 520 | + 'de-AT' => __('German (Austria)', 'event_espresso'), |
|
| 521 | + 'de-CH' => __('German (Switzerland)', 'event_espresso'), |
|
| 522 | + 'el' => __('Greek', 'event_espresso'), |
|
| 523 | + 'iw' => __('Hebrew', 'event_espresso'), |
|
| 524 | + 'hi' => __('Hindi', 'event_espresso'), |
|
| 525 | + 'hu' => __('Hungarian', 'event_espresso'), |
|
| 526 | + 'id' => __('Indonesian', 'event_espresso'), |
|
| 527 | + 'it' => __('Italian', 'event_espresso'), |
|
| 528 | + 'ja' => __('Japanese', 'event_espresso'), |
|
| 529 | + 'ko' => __('Korean', 'event_espresso'), |
|
| 530 | + 'lv' => __('Latvian', 'event_espresso'), |
|
| 531 | + 'lt' => __('Lithuanian', 'event_espresso'), |
|
| 532 | + 'no' => __('Norwegian', 'event_espresso'), |
|
| 533 | + 'fa' => __('Persian', 'event_espresso'), |
|
| 534 | + 'pl' => __('Polish', 'event_espresso'), |
|
| 535 | + 'pt' => __('Portuguese', 'event_espresso'), |
|
| 536 | + 'pt-BR' => __('Portuguese (Brazil)', 'event_espresso'), |
|
| 537 | + 'pt-PT' => __('Portuguese (Portugal)', 'event_espresso'), |
|
| 538 | + 'ro' => __('Romanian', 'event_espresso'), |
|
| 539 | + 'ru' => __('Russian', 'event_espresso'), |
|
| 540 | + 'sr' => __('Serbian', 'event_espresso'), |
|
| 541 | + 'sk' => __('Slovak', 'event_espresso'), |
|
| 542 | + 'sl' => __('Slovenian', 'event_espresso'), |
|
| 543 | + 'es' => __('Spanish', 'event_espresso'), |
|
| 544 | + 'es-419' => __('Spanish (Latin America)', 'event_espresso'), |
|
| 545 | + 'sv' => __('Swedish', 'event_espresso'), |
|
| 546 | + 'th' => __('Thai', 'event_espresso'), |
|
| 547 | + 'tr' => __('Turkish', 'event_espresso'), |
|
| 548 | + 'uk' => __('Ukrainian', 'event_espresso'), |
|
| 549 | + 'vi' => __('Vietnamese', 'event_espresso') |
|
| 551 | 550 | ), |
| 552 | 551 | array( |
| 553 | - 'html_label_text' => __( 'Language', 'event_espresso' ), |
|
| 554 | - 'html_help_text' => __( 'Forces the widget to render in a specific language.', 'event_espresso' ), |
|
| 555 | - 'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en' |
|
| 552 | + 'html_label_text' => __('Language', 'event_espresso'), |
|
| 553 | + 'html_help_text' => __('Forces the widget to render in a specific language.', 'event_espresso'), |
|
| 554 | + 'default' => isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en' |
|
| 556 | 555 | ) |
| 557 | 556 | ) |
| 558 | 557 | ) |
@@ -600,25 +599,25 @@ discard block |
||
| 600 | 599 | * @param EE_Registration_Config $EE_Registration_Config |
| 601 | 600 | * @return array |
| 602 | 601 | */ |
| 603 | - public static function update_admin_settings( EE_Registration_Config $EE_Registration_Config ) { |
|
| 602 | + public static function update_admin_settings(EE_Registration_Config $EE_Registration_Config) { |
|
| 604 | 603 | try { |
| 605 | 604 | $recaptcha_settings_form = EED_Recaptcha::_recaptcha_settings_form(); |
| 606 | 605 | // if not displaying a form, then check for form submission |
| 607 | - if ( $recaptcha_settings_form->was_submitted() ) { |
|
| 606 | + if ($recaptcha_settings_form->was_submitted()) { |
|
| 608 | 607 | // capture form data |
| 609 | 608 | $recaptcha_settings_form->receive_form_submission(); |
| 610 | 609 | // validate form data |
| 611 | - if ( $recaptcha_settings_form->is_valid() ) { |
|
| 610 | + if ($recaptcha_settings_form->is_valid()) { |
|
| 612 | 611 | // grab validated data from form |
| 613 | 612 | $valid_data = $recaptcha_settings_form->valid_data(); |
| 614 | 613 | // user proofing recaptcha: If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message. |
| 615 | 614 | if ( |
| 616 | - apply_filters( 'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', TRUE, $EE_Registration_Config ) |
|
| 615 | + apply_filters('FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', TRUE, $EE_Registration_Config) |
|
| 617 | 616 | && $valid_data['main_settings']['use_captcha'] |
| 618 | - && ( ! $EE_Registration_Config->use_captcha && ( empty( $valid_data['main_settings']['recaptcha_publickey'] ) || empty( $valid_data['main_settings']['recaptcha_privatekey'] ))) |
|
| 617 | + && ( ! $EE_Registration_Config->use_captcha && (empty($valid_data['main_settings']['recaptcha_publickey']) || empty($valid_data['main_settings']['recaptcha_privatekey']))) |
|
| 619 | 618 | ) { |
| 620 | 619 | $valid_data['main_settings']['use_captcha'] = FALSE; |
| 621 | - EE_Error::add_error( __('The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 620 | + EE_Error::add_error(__('The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 622 | 621 | } |
| 623 | 622 | $EE_Registration_Config->use_captcha = $valid_data['main_settings']['use_captcha']; |
| 624 | 623 | $EE_Registration_Config->recaptcha_publickey = $valid_data['main_settings']['recaptcha_publickey']; |
@@ -627,12 +626,12 @@ discard block |
||
| 627 | 626 | $EE_Registration_Config->recaptcha_theme = $valid_data['appearance_settings']['recaptcha_theme']; |
| 628 | 627 | $EE_Registration_Config->recaptcha_language = $valid_data['appearance_settings']['recaptcha_language']; |
| 629 | 628 | } else { |
| 630 | - if ( $recaptcha_settings_form->submission_error_message() != '' ) { |
|
| 631 | - EE_Error::add_error( $recaptcha_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 629 | + if ($recaptcha_settings_form->submission_error_message() != '') { |
|
| 630 | + EE_Error::add_error($recaptcha_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
| 632 | 631 | } |
| 633 | 632 | } |
| 634 | 633 | } |
| 635 | - } catch( EE_Error $e ) { |
|
| 634 | + } catch (EE_Error $e) { |
|
| 636 | 635 | $e->get_error(); |
| 637 | 636 | } |
| 638 | 637 | |
@@ -17,27 +17,27 @@ |
||
| 17 | 17 | class TicketSelectorIframeEmbedButton extends IframeEmbedButton |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * TicketSelectorIframeEmbedButton constructor. |
|
| 22 | - */ |
|
| 23 | - public function __construct() |
|
| 24 | - { |
|
| 25 | - parent::__construct( |
|
| 26 | - esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
| 27 | - 'ticket_selector' |
|
| 28 | - ); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Adds an iframe embed code button to the Event editor. |
|
| 35 | - */ |
|
| 36 | - public function addEventEditorIframeEmbedButton() |
|
| 37 | - { |
|
| 38 | - // add button for iframe code to event editor. |
|
| 39 | - $this->addEventEditorIframeEmbedButtonFilter(); |
|
| 40 | - } |
|
| 20 | + /** |
|
| 21 | + * TicketSelectorIframeEmbedButton constructor. |
|
| 22 | + */ |
|
| 23 | + public function __construct() |
|
| 24 | + { |
|
| 25 | + parent::__construct( |
|
| 26 | + esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
| 27 | + 'ticket_selector' |
|
| 28 | + ); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Adds an iframe embed code button to the Event editor. |
|
| 35 | + */ |
|
| 36 | + public function addEventEditorIframeEmbedButton() |
|
| 37 | + { |
|
| 38 | + // add button for iframe code to event editor. |
|
| 39 | + $this->addEventEditorIframeEmbedButtonFilter(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | use EventEspresso\core\libraries\iframe_display\IframeEmbedButton; |
| 5 | 5 | |
| 6 | -defined( 'ABSPATH' ) || exit; |
|
| 6 | +defined('ABSPATH') || exit; |
|
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | public function __construct() |
| 24 | 24 | { |
| 25 | 25 | parent::__construct( |
| 26 | - esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
| 26 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
| 27 | 27 | 'ticket_selector' |
| 28 | 28 | ); |
| 29 | 29 | } |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | use EventEspresso\core\libraries\iframe_display\Iframe; |
| 5 | 5 | |
| 6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 7 | - exit( 'No direct script access allowed' ); |
|
| 6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 7 | + exit('No direct script access allowed'); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | * @return mixed|null |
| 27 | 27 | * @throws \EE_Error |
| 28 | 28 | */ |
| 29 | - public static function create( $class_name, $arguments = array() ) { |
|
| 30 | - if ( empty( $class_name ) ) { |
|
| 29 | + public static function create($class_name, $arguments = array()) { |
|
| 30 | + if (empty($class_name)) { |
|
| 31 | 31 | throw new \EE_Error( |
| 32 | - __( 'You must provide a class name in order to instantiate it.', 'event_espresso' ) |
|
| 32 | + __('You must provide a class name in order to instantiate it.', 'event_espresso') |
|
| 33 | 33 | ); |
| 34 | 34 | } |
| 35 | 35 | // if ( ! class_exists( $class_name ) ) { |
@@ -41,20 +41,20 @@ discard block |
||
| 41 | 41 | // ); |
| 42 | 42 | // } |
| 43 | 43 | $object = null; |
| 44 | - switch ( $class_name ) { |
|
| 44 | + switch ($class_name) { |
|
| 45 | 45 | |
| 46 | 46 | case 'EE_Request' : |
| 47 | - $object = new \EE_Request( $_GET, $_POST, $_COOKIE ); |
|
| 47 | + $object = new \EE_Request($_GET, $_POST, $_COOKIE); |
|
| 48 | 48 | break; |
| 49 | 49 | |
| 50 | 50 | case 'Iframe' : |
| 51 | - $title = isset( $arguments['title'] ) ? $arguments['title'] : null; |
|
| 52 | - $content = isset( $arguments['content'] ) ? $arguments['content'] : null; |
|
| 53 | - $object = new Iframe( $title, $content ); |
|
| 51 | + $title = isset($arguments['title']) ? $arguments['title'] : null; |
|
| 52 | + $content = isset($arguments['content']) ? $arguments['content'] : null; |
|
| 53 | + $object = new Iframe($title, $content); |
|
| 54 | 54 | break; |
| 55 | 55 | |
| 56 | 56 | default : |
| 57 | - $object = new $class_name( $arguments ); |
|
| 57 | + $object = new $class_name($arguments); |
|
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | /** |
| 6 | 6 | * ************************************************************************ |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | $action_or_filter = 'action' |
| 44 | 44 | ) { |
| 45 | 45 | $action_or_filter = $action_or_filter === 'action' |
| 46 | - ? esc_html__( 'action', 'event_espresso' ) |
|
| 47 | - : esc_html__( 'filter', 'event_espresso' ); |
|
| 46 | + ? esc_html__('action', 'event_espresso') |
|
| 47 | + : esc_html__('filter', 'event_espresso'); |
|
| 48 | 48 | EE_Error::doing_it_wrong( |
| 49 | 49 | $deprecated_filter, |
| 50 | 50 | sprintf( |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param \EE_Checkout $checkout |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
| 71 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
| 72 | 72 | // list of old filters |
| 73 | 73 | $deprecated_filters = array( |
| 74 | 74 | 'update_registration_details' => true, |
@@ -78,16 +78,16 @@ discard block |
||
| 78 | 78 | 'proceed_to' => true, |
| 79 | 79 | ); |
| 80 | 80 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
| 81 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
| 81 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
| 82 | 82 | // was this filter called ? |
| 83 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
| 83 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
| 84 | 84 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
| 85 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
| 85 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
| 86 | 86 | EE_Error::doing_it_wrong( |
| 87 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 87 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 88 | 88 | sprintf( |
| 89 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
| 90 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 89 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
| 90 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 91 | 91 | '<br />', |
| 92 | 92 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
| 93 | 93 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -96,24 +96,24 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
| 99 | + unset($deprecated_filters[$deprecated_filter]); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | - if ( ! empty( $deprecated_filters )) { |
|
| 103 | - |
|
| 104 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
| 105 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
| 106 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
| 107 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
| 108 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
| 109 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
| 102 | + if ( ! empty($deprecated_filters)) { |
|
| 103 | + |
|
| 104 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
| 105 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
| 106 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
| 107 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
| 108 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
| 109 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
| 110 | 110 | } |
| 111 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
| 112 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
| 113 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
| 111 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 112 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
| 113 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
| 114 | 114 | } |
| 115 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
| 116 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
| 115 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
| 116 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | return $submit_button_text; |
| 122 | 122 | |
| 123 | 123 | } |
| 124 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
| 124 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | |
@@ -132,16 +132,16 @@ discard block |
||
| 132 | 132 | * @param \EE_Checkout $checkout |
| 133 | 133 | * @param boolean $status_updates |
| 134 | 134 | */ |
| 135 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
| 135 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
| 136 | 136 | $action_ref = NULL; |
| 137 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | - if ( $action_ref ) { |
|
| 137 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | + if ($action_ref) { |
|
| 140 | 140 | |
| 141 | 141 | EE_Error::doing_it_wrong( |
| 142 | 142 | $action_ref, |
| 143 | 143 | sprintf( |
| 144 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
| 144 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
| 145 | 145 | '<br />', |
| 146 | 146 | '/core/business/EE_Transaction_Processor.class.php', |
| 147 | 147 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -151,39 +151,39 @@ discard block |
||
| 151 | 151 | ), |
| 152 | 152 | '4.6.0' |
| 153 | 153 | ); |
| 154 | - switch ( $action_ref ) { |
|
| 154 | + switch ($action_ref) { |
|
| 155 | 155 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
| 156 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
| 156 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
| 157 | 157 | break; |
| 158 | 158 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
| 159 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
| 159 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
| 160 | 160 | break; |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
| 164 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
| 165 | 165 | /** |
| 166 | 166 | * ee_deprecated_finalize_registration |
| 167 | 167 | * |
| 168 | 168 | * @param EE_Registration $registration |
| 169 | 169 | */ |
| 170 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
| 171 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | - if ( $action_ref ) { |
|
| 170 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
| 171 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | + if ($action_ref) { |
|
| 173 | 173 | EE_Error::doing_it_wrong( |
| 174 | 174 | $action_ref, |
| 175 | 175 | sprintf( |
| 176 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
| 176 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
| 177 | 177 | '<br />', |
| 178 | 178 | '/core/business/EE_Registration_Processor.class.php', |
| 179 | 179 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
| 180 | 180 | ), |
| 181 | 181 | '4.6.0' |
| 182 | 182 | ); |
| 183 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
| 183 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
| 186 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
| 192 | 192 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
| 193 | 193 | */ |
| 194 | -function ee_deprecated_hooks(){ |
|
| 194 | +function ee_deprecated_hooks() { |
|
| 195 | 195 | /** |
| 196 | 196 | * @var $hooks array where keys are hook names, and their values are array{ |
| 197 | 197 | * @type string $version when deprecated |
@@ -202,25 +202,25 @@ discard block |
||
| 202 | 202 | $hooks = array( |
| 203 | 203 | 'AHEE__EE_System___do_setup_validations' => array( |
| 204 | 204 | 'version' => '4.6.0', |
| 205 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
| 205 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
| 206 | 206 | 'still_works' => FALSE |
| 207 | 207 | ) |
| 208 | 208 | ); |
| 209 | - foreach( $hooks as $name => $deprecation_info ){ |
|
| 210 | - if( has_action( $name ) ){ |
|
| 209 | + foreach ($hooks as $name => $deprecation_info) { |
|
| 210 | + if (has_action($name)) { |
|
| 211 | 211 | EE_Error::doing_it_wrong( |
| 212 | 212 | $name, |
| 213 | 213 | sprintf( |
| 214 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
| 215 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
| 216 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
| 214 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
| 215 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
| 216 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
| 217 | 217 | ), |
| 218 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ) |
|
| 218 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
| 219 | 219 | ); |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
| 223 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | * @return boolean |
| 232 | 232 | */ |
| 233 | 233 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
| 234 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
| 235 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
| 236 | - if( $in_use ) { |
|
| 234 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
| 235 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
| 236 | + if ($in_use) { |
|
| 237 | 237 | $msg = __( |
| 238 | 238 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
| 239 | 239 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -242,18 +242,18 @@ discard block |
||
| 242 | 242 | 'event_espresso' ) |
| 243 | 243 | ; |
| 244 | 244 | EE_Error::doing_it_wrong( |
| 245 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 245 | + __CLASS__.'::'.__FUNCTION__, |
|
| 246 | 246 | $msg, |
| 247 | 247 | '4.8.32.rc.000' |
| 248 | 248 | ); |
| 249 | 249 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
| 250 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 251 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 250 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 251 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | return $in_use; |
| 255 | 255 | } |
| 256 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
| 256 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -262,34 +262,34 @@ discard block |
||
| 262 | 262 | * @param EE_Admin_Page $admin_page |
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
| 265 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
| 266 | 266 | //check if the old hooks are in use. If not, do the default |
| 267 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 267 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | $req_data = $admin_page->get_request_data(); |
| 272 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
| 273 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
| 274 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
| 275 | - if ( ! $REG_ID || ! $qstns ) { |
|
| 276 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 272 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
| 273 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
| 274 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
| 275 | + if ( ! $REG_ID || ! $qstns) { |
|
| 276 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 277 | 277 | } |
| 278 | 278 | $success = TRUE; |
| 279 | 279 | |
| 280 | 280 | // allow others to get in on this awesome fun :D |
| 281 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
| 281 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
| 282 | 282 | // loop thru questions... FINALLY!!! |
| 283 | 283 | |
| 284 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
| 284 | + foreach ($qstns as $QST_ID => $qstn) { |
|
| 285 | 285 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
| 286 | - if ( !is_array($qstn) ) { |
|
| 287 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
| 286 | + if ( ! is_array($qstn)) { |
|
| 287 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
| 288 | 288 | continue; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
| 292 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
| 292 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
| 293 | 293 | //get answer |
| 294 | 294 | $query_params = array( |
| 295 | 295 | 0 => array( |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | ); |
| 301 | 301 | $answer = EEM_Answer::instance()->get_one($query_params); |
| 302 | 302 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
| 303 | - if ( ! $answer instanceof EE_Answer ) { |
|
| 303 | + if ( ! $answer instanceof EE_Answer) { |
|
| 304 | 304 | $set_values = array( |
| 305 | 305 | 'QST_ID' => $QST_ID, |
| 306 | 306 | 'REG_ID' => $REG_ID, |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | $what = __('Registration Form', 'event_espresso'); |
| 318 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
| 319 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
| 318 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
| 319 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 320 | 320 | exit; |
| 321 | 321 | } |
| 322 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
| 322 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
| 323 | 323 | /** |
| 324 | 324 | * Render the registration admin page's custom questions area in the old fashion |
| 325 | 325 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -332,31 +332,31 @@ discard block |
||
| 332 | 332 | * @return bool |
| 333 | 333 | * @throws \EE_Error |
| 334 | 334 | */ |
| 335 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
| 335 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
| 336 | 336 | //check if the old hooks are in use. If not, do the default |
| 337 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 337 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 339 | 339 | return $do_default_action; |
| 340 | 340 | } |
| 341 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
| 342 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
| 343 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
| 344 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
| 341 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
| 342 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
| 343 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
| 344 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
| 345 | 345 | |
| 346 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
| 346 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
| 347 | 347 | |
| 348 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
| 348 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
| 349 | 349 | $template_args = array( |
| 350 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
| 350 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
| 351 | 351 | 'reg_questions_form_action' => 'edit_registration', |
| 352 | 352 | 'REG_ID' => $registration->ID() |
| 353 | 353 | ); |
| 354 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 354 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 356 | 356 | //indicate that we should not do the default admin page code |
| 357 | 357 | return false; |
| 358 | 358 | } |
| 359 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
| 359 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
| 360 | 360 | |
| 361 | 361 | |
| 362 | 362 | |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | '4.9.0' |
| 398 | 398 | ); |
| 399 | 399 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
| 400 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 401 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
| 402 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
| 400 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 401 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
| 402 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
| 403 | 403 | return EE_Registry::instance()->load_lib( |
| 404 | 404 | 'Messages_Template_Defaults', |
| 405 | 405 | array( |
@@ -464,15 +464,15 @@ discard block |
||
| 464 | 464 | /** |
| 465 | 465 | * @param string $method |
| 466 | 466 | */ |
| 467 | - public function _class_is_deprecated( $method ) { |
|
| 467 | + public function _class_is_deprecated($method) { |
|
| 468 | 468 | EE_Error::doing_it_wrong( |
| 469 | - 'EE_messages::' . $method, |
|
| 470 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
| 469 | + 'EE_messages::'.$method, |
|
| 470 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
| 471 | 471 | '4.9.0', |
| 472 | 472 | '4.10.0.p' |
| 473 | 473 | ); |
| 474 | 474 | // Please use EE_Message_Resource_Manager instead |
| 475 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 475 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | |
@@ -482,10 +482,10 @@ discard block |
||
| 482 | 482 | * @param string $messenger_name |
| 483 | 483 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
| 484 | 484 | */ |
| 485 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
| 485 | + public function ensure_messenger_is_active($messenger_name) { |
|
| 486 | 486 | // EE_messages has been deprecated |
| 487 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 488 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
| 487 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 488 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
@@ -497,10 +497,10 @@ discard block |
||
| 497 | 497 | * @return bool true if it got activated (or was active) and false if not. |
| 498 | 498 | * @throws \EE_Error |
| 499 | 499 | */ |
| 500 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
| 500 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
| 501 | 501 | // EE_messages has been deprecated |
| 502 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 503 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
| 502 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 503 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | * they are already setup.) |
| 514 | 514 | * @return boolean an array of generated templates or false if nothing generated/activated. |
| 515 | 515 | */ |
| 516 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
| 516 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
| 517 | 517 | // EE_messages has been deprecated |
| 518 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 519 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
| 518 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 519 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
@@ -528,10 +528,10 @@ discard block |
||
| 528 | 528 | * |
| 529 | 529 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
| 530 | 530 | */ |
| 531 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 531 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
| 532 | 532 | // EE_messages has been deprecated |
| 533 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 534 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
| 533 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 534 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
@@ -541,10 +541,10 @@ discard block |
||
| 541 | 541 | * @param string $messenger |
| 542 | 542 | * @return EE_messenger | null |
| 543 | 543 | */ |
| 544 | - public function get_messenger_if_active( $messenger ) { |
|
| 544 | + public function get_messenger_if_active($messenger) { |
|
| 545 | 545 | // EE_messages has been deprecated |
| 546 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 547 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
| 546 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 547 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | * 'message_type' => null |
| 566 | 566 | * ) |
| 567 | 567 | */ |
| 568 | - public function validate_for_use( EE_Message $message ) { |
|
| 568 | + public function validate_for_use(EE_Message $message) { |
|
| 569 | 569 | // EE_messages has been deprecated |
| 570 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 570 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 571 | 571 | return array( |
| 572 | 572 | 'messenger' => $message->messenger_object(), |
| 573 | 573 | 'message_type' => $message->message_type_object(), |
@@ -595,41 +595,41 @@ discard block |
||
| 595 | 595 | $send = true |
| 596 | 596 | ) { |
| 597 | 597 | // EE_messages has been deprecated |
| 598 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 598 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 599 | 599 | /** @type EE_Messages_Processor $processor */ |
| 600 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
| 600 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 601 | 601 | $error = false; |
| 602 | 602 | //try to intelligently determine what method we'll call based on the incoming data. |
| 603 | 603 | //if generating and sending are different then generate and send immediately. |
| 604 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
| 604 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
| 605 | 605 | //in the legacy system, when generating and sending were different, that means all the |
| 606 | 606 | //vars are already in the request object. So let's just use that. |
| 607 | 607 | try { |
| 608 | 608 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
| 609 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
| 610 | - $processor->generate_and_send_now( $mtg ); |
|
| 611 | - } catch ( EE_Error $e ) { |
|
| 609 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
| 610 | + $processor->generate_and_send_now($mtg); |
|
| 611 | + } catch (EE_Error $e) { |
|
| 612 | 612 | $error_msg = __( |
| 613 | 613 | 'Please note that a system message failed to send due to a technical issue.', |
| 614 | 614 | 'event_espresso' |
| 615 | 615 | ); |
| 616 | 616 | // add specific message for developers if WP_DEBUG in on |
| 617 | - $error_msg .= '||' . $e->getMessage(); |
|
| 618 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 617 | + $error_msg .= '||'.$e->getMessage(); |
|
| 618 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 619 | 619 | $error = true; |
| 620 | 620 | } |
| 621 | 621 | } else { |
| 622 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
| 622 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
| 623 | 623 | //let's find out if there were any errors and how many successfully were queued. |
| 624 | 624 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
| 625 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
| 625 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
| 626 | 626 | ); |
| 627 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
| 628 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
| 627 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
| 628 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
| 629 | 629 | $count_errors = $count_errors + $count_retry; |
| 630 | - if ( $count_errors > 0 ) { |
|
| 630 | + if ($count_errors > 0) { |
|
| 631 | 631 | $error = true; |
| 632 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
| 632 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
| 633 | 633 | $message = sprintf( |
| 634 | 634 | __( |
| 635 | 635 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | $count_errors, |
| 639 | 639 | $count_queued |
| 640 | 640 | ); |
| 641 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
| 641 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
| 642 | 642 | $message = sprintf( |
| 643 | 643 | __( |
| 644 | 644 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | $count_errors, |
| 648 | 648 | $count_queued |
| 649 | 649 | ); |
| 650 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
| 650 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
| 651 | 651 | $message = sprintf( |
| 652 | 652 | __( |
| 653 | 653 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -665,9 +665,9 @@ discard block |
||
| 665 | 665 | $count_errors |
| 666 | 666 | ); |
| 667 | 667 | } |
| 668 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 668 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
| 669 | 669 | } else { |
| 670 | - if ( $count_queued === 1 ) { |
|
| 670 | + if ($count_queued === 1) { |
|
| 671 | 671 | $message = sprintf( |
| 672 | 672 | __( |
| 673 | 673 | '%d message successfully queued for generation.', |
@@ -684,18 +684,18 @@ discard block |
||
| 684 | 684 | $count_queued |
| 685 | 685 | ); |
| 686 | 686 | } |
| 687 | - EE_Error::add_success( $message ); |
|
| 687 | + EE_Error::add_success($message); |
|
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | //if no error then return the generated message(s). |
| 691 | - if ( ! $error && ! $send ) { |
|
| 692 | - $generated_queue = $processor->generate_queue( false ); |
|
| 691 | + if ( ! $error && ! $send) { |
|
| 692 | + $generated_queue = $processor->generate_queue(false); |
|
| 693 | 693 | //get message and return. |
| 694 | 694 | $generated_queue->get_message_repository()->rewind(); |
| 695 | 695 | $messages = array(); |
| 696 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
| 696 | + while ($generated_queue->get_message_repository()->valid()) { |
|
| 697 | 697 | $message = $generated_queue->get_message_repository()->current(); |
| 698 | - if ( $message instanceof EE_Message ) { |
|
| 698 | + if ($message instanceof EE_Message) { |
|
| 699 | 699 | //set properties that might be expected by add-ons (backward compat) |
| 700 | 700 | $message->content = $message->content(); |
| 701 | 701 | $message->template_pack = $message->get_template_pack(); |
@@ -720,10 +720,10 @@ discard block |
||
| 720 | 720 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
| 721 | 721 | * @return string The body of the message. |
| 722 | 722 | */ |
| 723 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
| 723 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
| 724 | 724 | // EE_messages has been deprecated |
| 725 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 726 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
| 725 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 726 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | |
@@ -737,14 +737,14 @@ discard block |
||
| 737 | 737 | * |
| 738 | 738 | * @return bool success or fail. |
| 739 | 739 | */ |
| 740 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
| 740 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
| 741 | 741 | // EE_messages has been deprecated |
| 742 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 742 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 743 | 743 | //setup for sending to new method. |
| 744 | 744 | /** @type EE_Messages_Queue $queue */ |
| 745 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
| 745 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
| 746 | 746 | //make sure we have a proper message object |
| 747 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
| 747 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
| 748 | 748 | $msg = EE_Message_Factory::create( |
| 749 | 749 | array( |
| 750 | 750 | 'MSG_messenger' => $messenger, |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | } else { |
| 757 | 757 | $msg = $message; |
| 758 | 758 | } |
| 759 | - if ( ! $msg instanceof EE_Message ) { |
|
| 759 | + if ( ! $msg instanceof EE_Message) { |
|
| 760 | 760 | return false; |
| 761 | 761 | } |
| 762 | 762 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
| 763 | - if ( ! empty( $msg->content ) ) { |
|
| 764 | - $msg->set( 'MSG_content', $msg->content ); |
|
| 763 | + if ( ! empty($msg->content)) { |
|
| 764 | + $msg->set('MSG_content', $msg->content); |
|
| 765 | 765 | } |
| 766 | - $queue->add( $msg ); |
|
| 767 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
| 766 | + $queue->add($msg); |
|
| 767 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | |
@@ -778,11 +778,11 @@ discard block |
||
| 778 | 778 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
| 779 | 779 | * @throws \EE_Error |
| 780 | 780 | */ |
| 781 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
| 781 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
| 782 | 782 | // EE_messages has been deprecated |
| 783 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 784 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 785 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
| 783 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 784 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 785 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | |
@@ -793,11 +793,11 @@ discard block |
||
| 793 | 793 | * @param string $message_type_name name of EE_message_type |
| 794 | 794 | * @return array |
| 795 | 795 | */ |
| 796 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
| 796 | + public function get_fields($messenger_name, $message_type_name) { |
|
| 797 | 797 | // EE_messages has been deprecated |
| 798 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 799 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 800 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
| 798 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 799 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 800 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | |
@@ -811,13 +811,13 @@ discard block |
||
| 811 | 811 | * @return array multidimensional array of messenger and message_type objects |
| 812 | 812 | * (messengers index, and message_type index); |
| 813 | 813 | */ |
| 814 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
| 814 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
| 815 | 815 | // EE_messages has been deprecated |
| 816 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 817 | - if ( $skip_cache ) { |
|
| 816 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 817 | + if ($skip_cache) { |
|
| 818 | 818 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
| 819 | 819 | } |
| 820 | - switch ( $type ) { |
|
| 820 | + switch ($type) { |
|
| 821 | 821 | case 'messengers' : |
| 822 | 822 | return array( |
| 823 | 823 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | */ |
| 847 | 847 | public function get_active_messengers() { |
| 848 | 848 | // EE_messages has been deprecated |
| 849 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 849 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 850 | 850 | return $this->_message_resource_manager->active_messengers(); |
| 851 | 851 | } |
| 852 | 852 | |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | public function get_active_message_types() { |
| 860 | 860 | // EE_messages has been deprecated |
| 861 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 861 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 862 | 862 | return $this->_message_resource_manager->list_of_active_message_types(); |
| 863 | 863 | } |
| 864 | 864 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | */ |
| 871 | 871 | public function get_active_message_type_objects() { |
| 872 | 872 | // EE_messages has been deprecated |
| 873 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 873 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 874 | 874 | return $this->_message_resource_manager->get_active_message_type_objects(); |
| 875 | 875 | } |
| 876 | 876 | |
@@ -882,10 +882,10 @@ discard block |
||
| 882 | 882 | * @param string $messenger The messenger being checked |
| 883 | 883 | * @return EE_message_type[] (or empty array if none present) |
| 884 | 884 | */ |
| 885 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
| 885 | + public function get_active_message_types_per_messenger($messenger) { |
|
| 886 | 886 | // EE_messages has been deprecated |
| 887 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 888 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
| 887 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 888 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | |
@@ -896,10 +896,10 @@ discard block |
||
| 896 | 896 | * @param string $message_type The string should correspond to a message type. |
| 897 | 897 | * @return EE_message_type|null |
| 898 | 898 | */ |
| 899 | - public function get_active_message_type( $messenger, $message_type ) { |
|
| 899 | + public function get_active_message_type($messenger, $message_type) { |
|
| 900 | 900 | // EE_messages has been deprecated |
| 901 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 902 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
| 901 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 902 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | */ |
| 911 | 911 | public function get_installed_message_types() { |
| 912 | 912 | // EE_messages has been deprecated |
| 913 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 913 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 914 | 914 | return $this->_message_resource_manager->installed_message_types(); |
| 915 | 915 | } |
| 916 | 916 | |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | */ |
| 923 | 923 | public function get_installed_messengers() { |
| 924 | 924 | // EE_messages has been deprecated |
| 925 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 925 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 926 | 926 | return $this->_message_resource_manager->installed_messengers(); |
| 927 | 927 | } |
| 928 | 928 | |
@@ -933,10 +933,10 @@ discard block |
||
| 933 | 933 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
| 934 | 934 | * @return array |
| 935 | 935 | */ |
| 936 | - public function get_all_contexts( $slugs_only = true ) { |
|
| 936 | + public function get_all_contexts($slugs_only = true) { |
|
| 937 | 937 | // EE_messages has been deprecated |
| 938 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 939 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
| 938 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 939 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | add_filter( |
| 996 | 996 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
| 997 | 997 | function($event_list_iframe_css) { |
| 998 | - if ( ! has_filter( 'FHEE__EventsArchiveIframe__event_list_iframe__css' )) { |
|
| 998 | + if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
| 999 | 999 | return $event_list_iframe_css; |
| 1000 | 1000 | } |
| 1001 | 1001 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | add_filter( |
| 1016 | 1016 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
| 1017 | 1017 | function($event_list_iframe_js) { |
| 1018 | - if ( ! has_filter( 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js' )) { |
|
| 1018 | + if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
| 1019 | 1019 | return $event_list_iframe_js; |
| 1020 | 1020 | } |
| 1021 | 1021 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | * setTicketMinAndMax |
| 240 | 240 | * |
| 241 | 241 | * @param int $remaining |
| 242 | - * @return array |
|
| 242 | + * @return integer[] |
|
| 243 | 243 | */ |
| 244 | 244 | protected function setTicketMinAndMax($remaining) |
| 245 | 245 | { |
@@ -16,461 +16,461 @@ |
||
| 16 | 16 | class TicketSelectorRowStandard extends TicketSelectorRow |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var TicketDetails $ticket_details |
|
| 21 | - */ |
|
| 22 | - protected $ticket_details; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
| 26 | - */ |
|
| 27 | - protected $template_settings; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var \EE_Tax_Config $tax_settings |
|
| 31 | - */ |
|
| 32 | - protected $tax_settings; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var boolean $required_ticket_sold_out |
|
| 36 | - */ |
|
| 37 | - protected $required_ticket_sold_out; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var boolean $prices_displayed_including_taxes |
|
| 41 | - */ |
|
| 42 | - protected $prices_displayed_including_taxes; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var string $event_status |
|
| 46 | - */ |
|
| 47 | - protected $event_status; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @var int $row |
|
| 51 | - */ |
|
| 52 | - protected $row; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @var int $cols |
|
| 56 | - */ |
|
| 57 | - protected $cols; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var boolean $hidden_input_qty |
|
| 61 | - */ |
|
| 62 | - protected $hidden_input_qty; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @var string $ticket_datetime_classes |
|
| 66 | - */ |
|
| 67 | - protected $ticket_datetime_classes; |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * TicketDetails constructor. |
|
| 73 | - * |
|
| 74 | - * @param \EE_Ticket $ticket |
|
| 75 | - * @param TicketDetails $ticket_details |
|
| 76 | - * @param \EE_Ticket_Selector_Config $template_settings |
|
| 77 | - * @param \EE_Tax_Config $tax_settings |
|
| 78 | - * @param int $max_atndz |
|
| 79 | - * @param int $row |
|
| 80 | - * @param int $cols |
|
| 81 | - * @param boolean $required_ticket_sold_out |
|
| 82 | - * @param string $event_status |
|
| 83 | - * @param string $date_format |
|
| 84 | - * @param string $ticket_datetime_classes |
|
| 85 | - */ |
|
| 86 | - public function __construct( |
|
| 87 | - \EE_Ticket $ticket, |
|
| 88 | - TicketDetails $ticket_details, |
|
| 89 | - \EE_Ticket_Selector_Config $template_settings, |
|
| 90 | - \EE_Tax_Config $tax_settings, |
|
| 91 | - $max_atndz, |
|
| 92 | - $row, |
|
| 93 | - $cols, |
|
| 94 | - $required_ticket_sold_out, |
|
| 95 | - $event_status, |
|
| 96 | - $date_format, |
|
| 97 | - $ticket_datetime_classes |
|
| 98 | - ) { |
|
| 99 | - $this->ticket = $ticket; |
|
| 100 | - $this->ticket_details = $ticket_details; |
|
| 101 | - $this->template_settings = $template_settings; |
|
| 102 | - $this->tax_settings = $tax_settings; |
|
| 103 | - $this->max_atndz = $max_atndz; |
|
| 104 | - $this->row = $row; |
|
| 105 | - $this->cols = $cols; |
|
| 106 | - $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
| 107 | - $this->event_status = $event_status; |
|
| 108 | - $this->date_format = $date_format; |
|
| 109 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
| 110 | - parent::__construct($ticket, $max_atndz, $date_format); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * other ticket rows will need to know if a required ticket is sold out, |
|
| 117 | - * so that they are not offered for sale |
|
| 118 | - * |
|
| 119 | - * @return boolean |
|
| 120 | - */ |
|
| 121 | - public function getRequiredTicketSoldOut() |
|
| 122 | - { |
|
| 123 | - return $this->required_ticket_sold_out; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @return int |
|
| 130 | - */ |
|
| 131 | - public function getCols() |
|
| 132 | - { |
|
| 133 | - return $this->cols; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * getHtml |
|
| 140 | - * |
|
| 141 | - * @return string |
|
| 142 | - * @throws \EE_Error |
|
| 143 | - */ |
|
| 144 | - public function getHtml() |
|
| 145 | - { |
|
| 146 | - $min = 0; |
|
| 147 | - $max = $this->ticket->max(); |
|
| 148 | - $remaining = $this->ticket->remaining(); |
|
| 149 | - if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
| 150 | - list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
| 151 | - } else { |
|
| 152 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
| 153 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
| 154 | - ? $this->ticket->start_date() |
|
| 155 | - : $this->required_ticket_sold_out; |
|
| 156 | - } |
|
| 157 | - list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
| 158 | - list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
| 159 | - /** |
|
| 160 | - * Allow plugins to hook in and abort the generation and display of this row to do |
|
| 161 | - * something else if they want. |
|
| 162 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
| 163 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
| 164 | - * current row. |
|
| 165 | - * |
|
| 166 | - * @var string|bool |
|
| 167 | - */ |
|
| 168 | - $ticket_selector_row_html = apply_filters( |
|
| 169 | - 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
| 170 | - false, |
|
| 171 | - $this->ticket, |
|
| 172 | - $max, |
|
| 173 | - $min, |
|
| 174 | - $this->required_ticket_sold_out, |
|
| 175 | - $ticket_price, |
|
| 176 | - $ticket_bundle, |
|
| 177 | - $ticket_status, |
|
| 178 | - $status_class |
|
| 179 | - ); |
|
| 180 | - if ($ticket_selector_row_html !== false) { |
|
| 181 | - return $ticket_selector_row_html; |
|
| 182 | - } |
|
| 183 | - $ticket_selector_row_html = \EEH_HTML::tr( |
|
| 184 | - '', '', |
|
| 185 | - "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
| 186 | - ); |
|
| 187 | - /** |
|
| 188 | - * Allow plugins to hook in and abort the generation and display of the contents of this |
|
| 189 | - * row to do something else if they want. |
|
| 190 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
| 191 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
| 192 | - * current row. |
|
| 193 | - * |
|
| 194 | - * @var string|bool |
|
| 195 | - */ |
|
| 196 | - $new_row_cells_content = apply_filters( |
|
| 197 | - 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
| 198 | - false, |
|
| 199 | - $this->ticket, |
|
| 200 | - $max, |
|
| 201 | - $min, |
|
| 202 | - $this->required_ticket_sold_out, |
|
| 203 | - $ticket_price, |
|
| 204 | - $ticket_bundle, |
|
| 205 | - $ticket_status, |
|
| 206 | - $status_class |
|
| 207 | - ); |
|
| 208 | - if ($new_row_cells_content !== false) { |
|
| 209 | - return $ticket_selector_row_html |
|
| 210 | - . $new_row_cells_content |
|
| 211 | - . $this->ticketQtyAndIdHiddenInputs() |
|
| 212 | - . \EEH_HTML::trx(); |
|
| 213 | - } |
|
| 214 | - $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
| 215 | - |
|
| 216 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
| 217 | - $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
| 218 | - $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
| 219 | - $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
| 220 | - if (empty($this->ticket_status_display)) { |
|
| 221 | - if ($this->max_atndz === 1) { |
|
| 222 | - // only ONE attendee is allowed to register at a time |
|
| 223 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
| 224 | - } else if ($max > 0) { |
|
| 225 | - $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
| 229 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
| 230 | - $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
| 231 | - $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
| 232 | - $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - $this->row++; |
|
| 236 | - return $ticket_selector_row_html; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * setTicketMinAndMax |
|
| 243 | - * |
|
| 244 | - * @param int $remaining |
|
| 245 | - * @return array |
|
| 246 | - */ |
|
| 247 | - protected function setTicketMinAndMax($remaining) |
|
| 248 | - { |
|
| 249 | - // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
| 250 | - $max = min($remaining, $this->max_atndz); |
|
| 251 | - // but... we also want to restrict the number of tickets by the ticket max setting, |
|
| 252 | - // however, the max still can't be higher than what was just set above |
|
| 253 | - $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
| 254 | - // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
| 255 | - $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
| 256 | - // and if the ticket is required, then make sure that min qty is at least 1 |
|
| 257 | - $min = $this->ticket->required() ? max($min, 1) : $min; |
|
| 258 | - return array($min, $max); |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * getTicketPriceDetails |
|
| 264 | - * |
|
| 265 | - * @return array |
|
| 266 | - */ |
|
| 267 | - protected function getTicketPriceDetails() |
|
| 268 | - { |
|
| 269 | - $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
| 270 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
| 271 | - : $this->ticket->get_ticket_subtotal(); |
|
| 272 | - $ticket_bundle = false; |
|
| 273 | - $ticket_min = $this->ticket->min(); |
|
| 274 | - // for ticket bundles, set min and max qty the same |
|
| 275 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
| 276 | - $ticket_price *= $ticket_min; |
|
| 277 | - $ticket_bundle = true; |
|
| 278 | - } |
|
| 279 | - $ticket_price = apply_filters( |
|
| 280 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
| 281 | - $ticket_price, |
|
| 282 | - $this->ticket |
|
| 283 | - ); |
|
| 284 | - return array($ticket_price, $ticket_bundle); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * getTicketStatusClasses |
|
| 291 | - * |
|
| 292 | - * @param int $remaining |
|
| 293 | - * @return array |
|
| 294 | - * @throws \EE_Error |
|
| 295 | - */ |
|
| 296 | - protected function getTicketStatusClasses($remaining = 0) |
|
| 297 | - { |
|
| 298 | - // if a previous required ticket with the same sale start date is sold out, |
|
| 299 | - // then mark this ticket as sold out as well. |
|
| 300 | - // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
| 301 | - $tkt_status = $this->required_ticket_sold_out !== false |
|
| 302 | - && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
| 303 | - ? \EE_Ticket::sold_out |
|
| 304 | - : $this->ticket->ticket_status(); |
|
| 305 | - $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
| 306 | - ? \EE_Ticket::sold_out |
|
| 307 | - : $tkt_status; |
|
| 308 | - // check ticket status |
|
| 309 | - switch ($tkt_status) { |
|
| 310 | - // sold_out |
|
| 311 | - case \EE_Ticket::sold_out : |
|
| 312 | - $ticket_status = 'ticket-sales-sold-out'; |
|
| 313 | - $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
| 314 | - break; |
|
| 315 | - // expired |
|
| 316 | - case \EE_Ticket::expired : |
|
| 317 | - $ticket_status = 'ticket-sales-expired'; |
|
| 318 | - $status_class = 'ticket-sales-expired lt-grey-text'; |
|
| 319 | - break; |
|
| 320 | - // archived |
|
| 321 | - case \EE_Ticket::archived : |
|
| 322 | - $ticket_status = 'archived-ticket'; |
|
| 323 | - $status_class = 'archived-ticket hidden'; |
|
| 324 | - break; |
|
| 325 | - // pending |
|
| 326 | - case \EE_Ticket::pending : |
|
| 327 | - $ticket_status = 'ticket-pending'; |
|
| 328 | - $status_class = 'ticket-pending'; |
|
| 329 | - break; |
|
| 330 | - // onsale |
|
| 331 | - case \EE_Ticket::onsale : |
|
| 332 | - default : |
|
| 333 | - $ticket_status = 'ticket-on-sale'; |
|
| 334 | - $status_class = 'ticket-on-sale'; |
|
| 335 | - break; |
|
| 336 | - } |
|
| 337 | - $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
| 338 | - return array($tkt_status, $ticket_status, $status_class); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * ticketNameTableCell |
|
| 345 | - * |
|
| 346 | - * @return string |
|
| 347 | - * @throws \EE_Error |
|
| 348 | - */ |
|
| 349 | - protected function ticketNameTableCell() |
|
| 350 | - { |
|
| 351 | - $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
| 352 | - $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
| 353 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
| 354 | - if ($this->ticket->required()) { |
|
| 355 | - $html .= \EEH_HTML::p( |
|
| 356 | - apply_filters( |
|
| 357 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
| 358 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
| 359 | - ), |
|
| 360 | - '', 'ticket-required-pg' |
|
| 361 | - ); |
|
| 362 | - } |
|
| 363 | - $html .= \EEH_HTML::tdx(); |
|
| 364 | - return $html; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * ticketPriceTableCell |
|
| 371 | - * |
|
| 372 | - * @param float $ticket_price |
|
| 373 | - * @param bool $ticket_bundle |
|
| 374 | - * @return string |
|
| 375 | - * @throws \EE_Error |
|
| 376 | - */ |
|
| 377 | - protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
| 378 | - { |
|
| 379 | - $html = ''; |
|
| 380 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
| 381 | - $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
| 382 | - $html .= \EEH_Template::format_currency($ticket_price); |
|
| 383 | - $html .= $this->ticket->taxable() |
|
| 384 | - ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
| 385 | - : ''; |
|
| 386 | - $html .= ' '; |
|
| 387 | - $html .= \EEH_HTML::span( |
|
| 388 | - $ticket_bundle |
|
| 389 | - ? apply_filters( |
|
| 390 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
| 391 | - __(' / bundle', 'event_espresso') |
|
| 392 | - ) |
|
| 393 | - : apply_filters( |
|
| 394 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
| 395 | - __('', 'event_espresso') |
|
| 396 | - ), |
|
| 397 | - '', 'smaller-text no-bold' |
|
| 398 | - ); |
|
| 399 | - $html .= ' '; |
|
| 400 | - $html .= \EEH_HTML::tdx(); |
|
| 401 | - $this->cols++; |
|
| 402 | - } |
|
| 403 | - return $html; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * onlyOneAttendeeCanRegister |
|
| 410 | - * |
|
| 411 | - * @return string |
|
| 412 | - */ |
|
| 413 | - protected function onlyOneAttendeeCanRegister() |
|
| 414 | - { |
|
| 415 | - // display submit button since we have tickets available |
|
| 416 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 417 | - $this->hidden_input_qty = false; |
|
| 418 | - $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
| 419 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
| 420 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
| 421 | - $html .= $this->row === 1 ? ' checked="checked"' : ''; |
|
| 422 | - $html .= ' title=""/>'; |
|
| 423 | - return $html; |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - |
|
| 427 | - |
|
| 428 | - /** |
|
| 429 | - * ticketQuantitySelector |
|
| 430 | - * |
|
| 431 | - * @param int $min |
|
| 432 | - * @param int $max |
|
| 433 | - * @return string |
|
| 434 | - */ |
|
| 435 | - protected function ticketQuantitySelector($min = 0, $max = 0) |
|
| 436 | - { |
|
| 437 | - // display submit button since we have tickets available |
|
| 438 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 439 | - $this->hidden_input_qty = false; |
|
| 440 | - $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
| 441 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
| 442 | - $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
| 443 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
| 444 | - if ($min !== 0 && ! $this->ticket->required()) { |
|
| 445 | - $html .= '<option value="0"> 0 </option>'; |
|
| 446 | - } |
|
| 447 | - // offer ticket quantities from the min to the max |
|
| 448 | - for ($i = $min; $i <= $max; $i++) { |
|
| 449 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
| 450 | - } |
|
| 451 | - $html .= '</select>'; |
|
| 452 | - return $html; |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * getHiddenInputs |
|
| 459 | - * |
|
| 460 | - * @return string |
|
| 461 | - * @throws \EE_Error |
|
| 462 | - */ |
|
| 463 | - protected function ticketQtyAndIdHiddenInputs() |
|
| 464 | - { |
|
| 465 | - $html = ''; |
|
| 466 | - // depending on group reg we need to change the format for qty |
|
| 467 | - if ($this->hidden_input_qty) { |
|
| 468 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
| 469 | - } |
|
| 470 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
| 471 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
| 472 | - return $html; |
|
| 473 | - } |
|
| 19 | + /** |
|
| 20 | + * @var TicketDetails $ticket_details |
|
| 21 | + */ |
|
| 22 | + protected $ticket_details; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
| 26 | + */ |
|
| 27 | + protected $template_settings; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var \EE_Tax_Config $tax_settings |
|
| 31 | + */ |
|
| 32 | + protected $tax_settings; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var boolean $required_ticket_sold_out |
|
| 36 | + */ |
|
| 37 | + protected $required_ticket_sold_out; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var boolean $prices_displayed_including_taxes |
|
| 41 | + */ |
|
| 42 | + protected $prices_displayed_including_taxes; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var string $event_status |
|
| 46 | + */ |
|
| 47 | + protected $event_status; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @var int $row |
|
| 51 | + */ |
|
| 52 | + protected $row; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @var int $cols |
|
| 56 | + */ |
|
| 57 | + protected $cols; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var boolean $hidden_input_qty |
|
| 61 | + */ |
|
| 62 | + protected $hidden_input_qty; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @var string $ticket_datetime_classes |
|
| 66 | + */ |
|
| 67 | + protected $ticket_datetime_classes; |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * TicketDetails constructor. |
|
| 73 | + * |
|
| 74 | + * @param \EE_Ticket $ticket |
|
| 75 | + * @param TicketDetails $ticket_details |
|
| 76 | + * @param \EE_Ticket_Selector_Config $template_settings |
|
| 77 | + * @param \EE_Tax_Config $tax_settings |
|
| 78 | + * @param int $max_atndz |
|
| 79 | + * @param int $row |
|
| 80 | + * @param int $cols |
|
| 81 | + * @param boolean $required_ticket_sold_out |
|
| 82 | + * @param string $event_status |
|
| 83 | + * @param string $date_format |
|
| 84 | + * @param string $ticket_datetime_classes |
|
| 85 | + */ |
|
| 86 | + public function __construct( |
|
| 87 | + \EE_Ticket $ticket, |
|
| 88 | + TicketDetails $ticket_details, |
|
| 89 | + \EE_Ticket_Selector_Config $template_settings, |
|
| 90 | + \EE_Tax_Config $tax_settings, |
|
| 91 | + $max_atndz, |
|
| 92 | + $row, |
|
| 93 | + $cols, |
|
| 94 | + $required_ticket_sold_out, |
|
| 95 | + $event_status, |
|
| 96 | + $date_format, |
|
| 97 | + $ticket_datetime_classes |
|
| 98 | + ) { |
|
| 99 | + $this->ticket = $ticket; |
|
| 100 | + $this->ticket_details = $ticket_details; |
|
| 101 | + $this->template_settings = $template_settings; |
|
| 102 | + $this->tax_settings = $tax_settings; |
|
| 103 | + $this->max_atndz = $max_atndz; |
|
| 104 | + $this->row = $row; |
|
| 105 | + $this->cols = $cols; |
|
| 106 | + $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
| 107 | + $this->event_status = $event_status; |
|
| 108 | + $this->date_format = $date_format; |
|
| 109 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
| 110 | + parent::__construct($ticket, $max_atndz, $date_format); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * other ticket rows will need to know if a required ticket is sold out, |
|
| 117 | + * so that they are not offered for sale |
|
| 118 | + * |
|
| 119 | + * @return boolean |
|
| 120 | + */ |
|
| 121 | + public function getRequiredTicketSoldOut() |
|
| 122 | + { |
|
| 123 | + return $this->required_ticket_sold_out; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @return int |
|
| 130 | + */ |
|
| 131 | + public function getCols() |
|
| 132 | + { |
|
| 133 | + return $this->cols; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * getHtml |
|
| 140 | + * |
|
| 141 | + * @return string |
|
| 142 | + * @throws \EE_Error |
|
| 143 | + */ |
|
| 144 | + public function getHtml() |
|
| 145 | + { |
|
| 146 | + $min = 0; |
|
| 147 | + $max = $this->ticket->max(); |
|
| 148 | + $remaining = $this->ticket->remaining(); |
|
| 149 | + if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
| 150 | + list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
| 151 | + } else { |
|
| 152 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
| 153 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
| 154 | + ? $this->ticket->start_date() |
|
| 155 | + : $this->required_ticket_sold_out; |
|
| 156 | + } |
|
| 157 | + list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
| 158 | + list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
| 159 | + /** |
|
| 160 | + * Allow plugins to hook in and abort the generation and display of this row to do |
|
| 161 | + * something else if they want. |
|
| 162 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
| 163 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
| 164 | + * current row. |
|
| 165 | + * |
|
| 166 | + * @var string|bool |
|
| 167 | + */ |
|
| 168 | + $ticket_selector_row_html = apply_filters( |
|
| 169 | + 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
| 170 | + false, |
|
| 171 | + $this->ticket, |
|
| 172 | + $max, |
|
| 173 | + $min, |
|
| 174 | + $this->required_ticket_sold_out, |
|
| 175 | + $ticket_price, |
|
| 176 | + $ticket_bundle, |
|
| 177 | + $ticket_status, |
|
| 178 | + $status_class |
|
| 179 | + ); |
|
| 180 | + if ($ticket_selector_row_html !== false) { |
|
| 181 | + return $ticket_selector_row_html; |
|
| 182 | + } |
|
| 183 | + $ticket_selector_row_html = \EEH_HTML::tr( |
|
| 184 | + '', '', |
|
| 185 | + "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
| 186 | + ); |
|
| 187 | + /** |
|
| 188 | + * Allow plugins to hook in and abort the generation and display of the contents of this |
|
| 189 | + * row to do something else if they want. |
|
| 190 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
| 191 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
| 192 | + * current row. |
|
| 193 | + * |
|
| 194 | + * @var string|bool |
|
| 195 | + */ |
|
| 196 | + $new_row_cells_content = apply_filters( |
|
| 197 | + 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
| 198 | + false, |
|
| 199 | + $this->ticket, |
|
| 200 | + $max, |
|
| 201 | + $min, |
|
| 202 | + $this->required_ticket_sold_out, |
|
| 203 | + $ticket_price, |
|
| 204 | + $ticket_bundle, |
|
| 205 | + $ticket_status, |
|
| 206 | + $status_class |
|
| 207 | + ); |
|
| 208 | + if ($new_row_cells_content !== false) { |
|
| 209 | + return $ticket_selector_row_html |
|
| 210 | + . $new_row_cells_content |
|
| 211 | + . $this->ticketQtyAndIdHiddenInputs() |
|
| 212 | + . \EEH_HTML::trx(); |
|
| 213 | + } |
|
| 214 | + $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
| 215 | + |
|
| 216 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
| 217 | + $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
| 218 | + $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
| 219 | + $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
| 220 | + if (empty($this->ticket_status_display)) { |
|
| 221 | + if ($this->max_atndz === 1) { |
|
| 222 | + // only ONE attendee is allowed to register at a time |
|
| 223 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
| 224 | + } else if ($max > 0) { |
|
| 225 | + $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
| 229 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
| 230 | + $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
| 231 | + $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
| 232 | + $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + $this->row++; |
|
| 236 | + return $ticket_selector_row_html; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * setTicketMinAndMax |
|
| 243 | + * |
|
| 244 | + * @param int $remaining |
|
| 245 | + * @return array |
|
| 246 | + */ |
|
| 247 | + protected function setTicketMinAndMax($remaining) |
|
| 248 | + { |
|
| 249 | + // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
| 250 | + $max = min($remaining, $this->max_atndz); |
|
| 251 | + // but... we also want to restrict the number of tickets by the ticket max setting, |
|
| 252 | + // however, the max still can't be higher than what was just set above |
|
| 253 | + $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
| 254 | + // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
| 255 | + $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
| 256 | + // and if the ticket is required, then make sure that min qty is at least 1 |
|
| 257 | + $min = $this->ticket->required() ? max($min, 1) : $min; |
|
| 258 | + return array($min, $max); |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * getTicketPriceDetails |
|
| 264 | + * |
|
| 265 | + * @return array |
|
| 266 | + */ |
|
| 267 | + protected function getTicketPriceDetails() |
|
| 268 | + { |
|
| 269 | + $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
| 270 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
| 271 | + : $this->ticket->get_ticket_subtotal(); |
|
| 272 | + $ticket_bundle = false; |
|
| 273 | + $ticket_min = $this->ticket->min(); |
|
| 274 | + // for ticket bundles, set min and max qty the same |
|
| 275 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
| 276 | + $ticket_price *= $ticket_min; |
|
| 277 | + $ticket_bundle = true; |
|
| 278 | + } |
|
| 279 | + $ticket_price = apply_filters( |
|
| 280 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
| 281 | + $ticket_price, |
|
| 282 | + $this->ticket |
|
| 283 | + ); |
|
| 284 | + return array($ticket_price, $ticket_bundle); |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * getTicketStatusClasses |
|
| 291 | + * |
|
| 292 | + * @param int $remaining |
|
| 293 | + * @return array |
|
| 294 | + * @throws \EE_Error |
|
| 295 | + */ |
|
| 296 | + protected function getTicketStatusClasses($remaining = 0) |
|
| 297 | + { |
|
| 298 | + // if a previous required ticket with the same sale start date is sold out, |
|
| 299 | + // then mark this ticket as sold out as well. |
|
| 300 | + // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
| 301 | + $tkt_status = $this->required_ticket_sold_out !== false |
|
| 302 | + && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
| 303 | + ? \EE_Ticket::sold_out |
|
| 304 | + : $this->ticket->ticket_status(); |
|
| 305 | + $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
| 306 | + ? \EE_Ticket::sold_out |
|
| 307 | + : $tkt_status; |
|
| 308 | + // check ticket status |
|
| 309 | + switch ($tkt_status) { |
|
| 310 | + // sold_out |
|
| 311 | + case \EE_Ticket::sold_out : |
|
| 312 | + $ticket_status = 'ticket-sales-sold-out'; |
|
| 313 | + $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
| 314 | + break; |
|
| 315 | + // expired |
|
| 316 | + case \EE_Ticket::expired : |
|
| 317 | + $ticket_status = 'ticket-sales-expired'; |
|
| 318 | + $status_class = 'ticket-sales-expired lt-grey-text'; |
|
| 319 | + break; |
|
| 320 | + // archived |
|
| 321 | + case \EE_Ticket::archived : |
|
| 322 | + $ticket_status = 'archived-ticket'; |
|
| 323 | + $status_class = 'archived-ticket hidden'; |
|
| 324 | + break; |
|
| 325 | + // pending |
|
| 326 | + case \EE_Ticket::pending : |
|
| 327 | + $ticket_status = 'ticket-pending'; |
|
| 328 | + $status_class = 'ticket-pending'; |
|
| 329 | + break; |
|
| 330 | + // onsale |
|
| 331 | + case \EE_Ticket::onsale : |
|
| 332 | + default : |
|
| 333 | + $ticket_status = 'ticket-on-sale'; |
|
| 334 | + $status_class = 'ticket-on-sale'; |
|
| 335 | + break; |
|
| 336 | + } |
|
| 337 | + $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
| 338 | + return array($tkt_status, $ticket_status, $status_class); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * ticketNameTableCell |
|
| 345 | + * |
|
| 346 | + * @return string |
|
| 347 | + * @throws \EE_Error |
|
| 348 | + */ |
|
| 349 | + protected function ticketNameTableCell() |
|
| 350 | + { |
|
| 351 | + $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
| 352 | + $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
| 353 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
| 354 | + if ($this->ticket->required()) { |
|
| 355 | + $html .= \EEH_HTML::p( |
|
| 356 | + apply_filters( |
|
| 357 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
| 358 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
| 359 | + ), |
|
| 360 | + '', 'ticket-required-pg' |
|
| 361 | + ); |
|
| 362 | + } |
|
| 363 | + $html .= \EEH_HTML::tdx(); |
|
| 364 | + return $html; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * ticketPriceTableCell |
|
| 371 | + * |
|
| 372 | + * @param float $ticket_price |
|
| 373 | + * @param bool $ticket_bundle |
|
| 374 | + * @return string |
|
| 375 | + * @throws \EE_Error |
|
| 376 | + */ |
|
| 377 | + protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
| 378 | + { |
|
| 379 | + $html = ''; |
|
| 380 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
| 381 | + $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
| 382 | + $html .= \EEH_Template::format_currency($ticket_price); |
|
| 383 | + $html .= $this->ticket->taxable() |
|
| 384 | + ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
| 385 | + : ''; |
|
| 386 | + $html .= ' '; |
|
| 387 | + $html .= \EEH_HTML::span( |
|
| 388 | + $ticket_bundle |
|
| 389 | + ? apply_filters( |
|
| 390 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
| 391 | + __(' / bundle', 'event_espresso') |
|
| 392 | + ) |
|
| 393 | + : apply_filters( |
|
| 394 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
| 395 | + __('', 'event_espresso') |
|
| 396 | + ), |
|
| 397 | + '', 'smaller-text no-bold' |
|
| 398 | + ); |
|
| 399 | + $html .= ' '; |
|
| 400 | + $html .= \EEH_HTML::tdx(); |
|
| 401 | + $this->cols++; |
|
| 402 | + } |
|
| 403 | + return $html; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * onlyOneAttendeeCanRegister |
|
| 410 | + * |
|
| 411 | + * @return string |
|
| 412 | + */ |
|
| 413 | + protected function onlyOneAttendeeCanRegister() |
|
| 414 | + { |
|
| 415 | + // display submit button since we have tickets available |
|
| 416 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 417 | + $this->hidden_input_qty = false; |
|
| 418 | + $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
| 419 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
| 420 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
| 421 | + $html .= $this->row === 1 ? ' checked="checked"' : ''; |
|
| 422 | + $html .= ' title=""/>'; |
|
| 423 | + return $html; |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + |
|
| 427 | + |
|
| 428 | + /** |
|
| 429 | + * ticketQuantitySelector |
|
| 430 | + * |
|
| 431 | + * @param int $min |
|
| 432 | + * @param int $max |
|
| 433 | + * @return string |
|
| 434 | + */ |
|
| 435 | + protected function ticketQuantitySelector($min = 0, $max = 0) |
|
| 436 | + { |
|
| 437 | + // display submit button since we have tickets available |
|
| 438 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 439 | + $this->hidden_input_qty = false; |
|
| 440 | + $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
| 441 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
| 442 | + $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
| 443 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
| 444 | + if ($min !== 0 && ! $this->ticket->required()) { |
|
| 445 | + $html .= '<option value="0"> 0 </option>'; |
|
| 446 | + } |
|
| 447 | + // offer ticket quantities from the min to the max |
|
| 448 | + for ($i = $min; $i <= $max; $i++) { |
|
| 449 | + $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
| 450 | + } |
|
| 451 | + $html .= '</select>'; |
|
| 452 | + return $html; |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * getHiddenInputs |
|
| 459 | + * |
|
| 460 | + * @return string |
|
| 461 | + * @throws \EE_Error |
|
| 462 | + */ |
|
| 463 | + protected function ticketQtyAndIdHiddenInputs() |
|
| 464 | + { |
|
| 465 | + $html = ''; |
|
| 466 | + // depending on group reg we need to change the format for qty |
|
| 467 | + if ($this->hidden_input_qty) { |
|
| 468 | + $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
| 469 | + } |
|
| 470 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
| 471 | + $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
| 472 | + return $html; |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | 475 | } |
| 476 | 476 | // End of file TicketSelectorRowStandard.php |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | $ticket_selector_row_html = \EEH_HTML::tr( |
| 184 | 184 | '', '', |
| 185 | - "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
| 185 | + "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} ".espresso_get_object_css_class($this->ticket) |
|
| 186 | 186 | ); |
| 187 | 187 | /** |
| 188 | 188 | * Allow plugins to hook in and abort the generation and display of the contents of this |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
| 382 | 382 | $html .= \EEH_Template::format_currency($ticket_price); |
| 383 | 383 | $html .= $this->ticket->taxable() |
| 384 | - ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
| 384 | + ? \EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
| 385 | 385 | : ''; |
| 386 | 386 | $html .= ' '; |
| 387 | 387 | $html .= \EEH_HTML::span( |
@@ -415,9 +415,9 @@ discard block |
||
| 415 | 415 | // display submit button since we have tickets available |
| 416 | 416 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
| 417 | 417 | $this->hidden_input_qty = false; |
| 418 | - $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
| 419 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
| 420 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
| 418 | + $html = '<input type="radio" name="tkt-slctr-qty-'.$this->EVT_ID.'"'; |
|
| 419 | + $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"'; |
|
| 420 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="'.$this->row.'-1"'; |
|
| 421 | 421 | $html .= $this->row === 1 ? ' checked="checked"' : ''; |
| 422 | 422 | $html .= ' title=""/>'; |
| 423 | 423 | return $html; |
@@ -437,8 +437,8 @@ discard block |
||
| 437 | 437 | // display submit button since we have tickets available |
| 438 | 438 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
| 439 | 439 | $this->hidden_input_qty = false; |
| 440 | - $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
| 441 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
| 440 | + $html = '<select name="tkt-slctr-qty-'.$this->EVT_ID.'[]"'; |
|
| 441 | + $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"'; |
|
| 442 | 442 | $html .= ' class="ticket-selector-tbl-qty-slct">'; |
| 443 | 443 | // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
| 444 | 444 | if ($min !== 0 && ! $this->ticket->required()) { |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | } |
| 447 | 447 | // offer ticket quantities from the min to the max |
| 448 | 448 | for ($i = $min; $i <= $max; $i++) { |
| 449 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
| 449 | + $html .= '<option value="'.$i.'"> '.$i.' </option>'; |
|
| 450 | 450 | } |
| 451 | 451 | $html .= '</select>'; |
| 452 | 452 | return $html; |
@@ -465,10 +465,10 @@ discard block |
||
| 465 | 465 | $html = ''; |
| 466 | 466 | // depending on group reg we need to change the format for qty |
| 467 | 467 | if ($this->hidden_input_qty) { |
| 468 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
| 468 | + $html .= '<input type="hidden" name="tkt-slctr-qty-'.$this->EVT_ID.'[]" value="0"/>'; |
|
| 469 | 469 | } |
| 470 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
| 471 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
| 470 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-'.$this->EVT_ID.'[]"'; |
|
| 471 | + $html .= ' value="'.$this->ticket->ID().'"/>'; |
|
| 472 | 472 | return $html; |
| 473 | 473 | } |
| 474 | 474 | |