From ad7001a7955d4991c27720e183fc5544ee70c772 Mon Sep 17 00:00:00 2001 From: Franky Van Liedekerke Date: Fri, 30 Dec 2022 17:56:02 +0100 Subject: [PATCH] code standardization, space fixes and class functions+vars to public where undefined --- class-expressivedate.php | 12 +- class-qrcode.php | 684 +++++++++++++++++----------------- cli_mail.php | 10 +- eme-actions.php | 146 ++++---- eme-attendances.php | 22 +- eme-attributes.php | 4 +- eme-calendar.php | 52 +-- eme-categories.php | 26 +- eme-cleanup.php | 6 +- eme-countries.php | 32 +- eme-cron.php | 20 +- eme-discounts.php | 102 +++--- eme-events.php | 470 ++++++++++++------------ eme-filters.php | 32 +- eme-formfields.php | 768 +++++++++++++++++++-------------------- eme-functions.php | 306 ++++++++-------- eme-gdpr.php | 232 ++++++------ eme-holidays.php | 24 +- eme-ical.php | 26 +- eme-locations.php | 170 ++++----- eme-mailer.php | 128 +++---- eme-members.php | 388 ++++++++++---------- eme-options.php | 302 +++++++-------- eme-payments.php | 280 +++++++------- eme-people.php | 448 +++++++++++------------ eme-recurrence.php | 44 +-- eme-rsvp.php | 438 +++++++++++----------- eme-tasks.php | 122 +++---- eme-templates.php | 32 +- eme-translate.php | 6 +- eme-ui-helpers.php | 16 +- eme-widgets.php | 38 +- events-manager.php | 40 +- 33 files changed, 2715 insertions(+), 2711 deletions(-) diff --git a/class-expressivedate.php b/class-expressivedate.php index 558ad405..d0b3fc37 100644 --- a/class-expressivedate.php +++ b/class-expressivedate.php @@ -798,7 +798,7 @@ public function setTimestampFromString( $string ): ExpressiveDate { public function isWeekday(): bool { $day = $this->getDayOfWeek(); - return ! in_array( $day, array( 'Saturday', 'Sunday' ) ); + return ! in_array( $day, [ 'Saturday', 'Sunday' ] ); } /** @@ -837,7 +837,7 @@ public function getDifferenceInMonths( $compare = null ): string { $difference = $this->diff( $compare ); - list($years, $months) = explode( ':', $difference->format( '%y:%m' ) ); + [$years, $months] = explode( ':', $difference->format( '%y:%m' ) ); return ( ( $years * 12 ) + $months ) * $difference->format( '%r1' ); } @@ -895,7 +895,7 @@ public function getDifferenceInSeconds( $compare = null ) { $difference = $this->diff( $compare ); - list($days, $hours, $minutes, $seconds) = explode( ':', $difference->format( '%a:%h:%i:%s' ) ); + [$days, $hours, $minutes, $seconds] = explode( ':', $difference->format( '%a:%h:%i:%s' ) ); // Add the total amount of seconds in all the days. $seconds += ( $days * 24 * 60 * 60 ); @@ -920,8 +920,8 @@ public function getRelativeDate( $compare = null ) { $compare = new ExpressiveDate( 'now', $this->getTimezone() ); } - $units = array( 'second', 'minute', 'hour', 'day', 'week', 'month', 'year' ); - $values = array( 60, 60, 24, 7, 4.35, 12 ); + $units = [ 'second', 'minute', 'hour', 'day', 'week', 'month', 'year' ]; + $values = [ 60, 60, 24, 7, 4.35, 12 ]; // Get the difference between the two timestamps. We'll use this to cacluate the // actual time remaining. @@ -1027,7 +1027,7 @@ public function setWeekStartDay( $weekStartDay ) { if ( is_numeric( $weekStartDay ) ) { $this->weekStartDay = $weekStartDay; } else { - $this->weekStartDay = array_search( strtolower( $weekStartDay ), array( 'sunday', 'monday' ) ); + $this->weekStartDay = array_search( strtolower( $weekStartDay ), [ 'sunday', 'monday' ] ); } return $this; diff --git a/class-qrcode.php b/class-qrcode.php index 988031eb..f16b778f 100644 --- a/class-qrcode.php +++ b/class-qrcode.php @@ -26,39 +26,39 @@ class QRCode { - var $typeNumber; + public $typeNumber; - var $modules; + public $modules; - var $moduleCount; + public $moduleCount; - var $errorCorrectLevel; + public $errorCorrectLevel; - var $qrDataList; + public $qrDataList; - function __construct() { + public function __construct() { $this->typeNumber = 1; $this->errorCorrectLevel = QR_ERROR_CORRECT_LEVEL_H; - $this->qrDataList = array(); + $this->qrDataList = []; } - function getTypeNumber() { + public function getTypeNumber() { return $this->typeNumber; } - function setTypeNumber( $typeNumber ) { + public function setTypeNumber( $typeNumber ) { $this->typeNumber = $typeNumber; } - function getErrorCorrectLevel() { + public function getErrorCorrectLevel() { return $this->errorCorrectLevel; } - function setErrorCorrectLevel( $errorCorrectLevel ) { + public function setErrorCorrectLevel( $errorCorrectLevel ) { $this->errorCorrectLevel = $errorCorrectLevel; } - function addData( $data, $mode = 0 ) { + public function addData( $data, $mode = 0 ) { if ( $mode == 0 ) { $mode = QRUtil::getMode( $data ); @@ -91,23 +91,23 @@ function addData( $data, $mode = 0 ) { } } - function clearData() { - $this->qrDataList = array(); + public function clearData() { + $this->qrDataList = []; } - function addDataImpl( $qrData ) { + public function addDataImpl( $qrData ) { $this->qrDataList[] = $qrData; } - function getDataCount() { + public function getDataCount() { return count( $this->qrDataList ); } - function getData( $index ) { + public function getData( $index ) { return $this->qrDataList[ $index ]; } - function isDark( $row, $col ) { + public function isDark( $row, $col ) { if ( $this->modules[ $row ][ $col ] !== null ) { return $this->modules[ $row ][ $col ]; } else { @@ -115,25 +115,25 @@ function isDark( $row, $col ) { } } - function getModuleCount() { + public function getModuleCount() { return $this->moduleCount; } // used for converting fg/bg colors (e.g. #0000ff = 0x0000FF) // added 2015.07.27 ~ DoktorJ - function hex2rgb( $hex = 0x0 ) { - return array( + public function hex2rgb( $hex = 0x0 ) { + return [ 'r' => floor( $hex / 65536 ), 'g' => floor( $hex / 256 ) % 256, 'b' => $hex % 256, - ); + ]; } - function make() { + public function make() { $this->makeImpl( false, $this->getBestMaskPattern() ); } - function getBestMaskPattern() { + public function getBestMaskPattern() { $minLostPoint = 0; $pattern = 0; @@ -153,19 +153,19 @@ function getBestMaskPattern() { return $pattern; } - function createNullArray( $length ) { - $nullArray = array(); + public function createNullArray( $length ) { + $nullArray = []; for ( $i = 0; $i < $length; $i++ ) { $nullArray[] = null; } return $nullArray; } - function makeImpl( $test, $maskPattern ) { + public function makeImpl( $test, $maskPattern ) { $this->moduleCount = $this->typeNumber * 4 + 17; - $this->modules = array(); + $this->modules = []; for ( $i = 0; $i < $this->moduleCount; $i++ ) { $this->modules[] = self::createNullArray( $this->moduleCount ); } @@ -190,7 +190,7 @@ function makeImpl( $test, $maskPattern ) { $this->mapData( $data, $maskPattern ); } - function mapData( &$data, $maskPattern ) { + public function mapData( &$data, $maskPattern ) { $inc = -1; $row = $this->moduleCount - 1; @@ -240,7 +240,7 @@ function mapData( &$data, $maskPattern ) { } } - function setupPositionAdjustPattern() { + public function setupPositionAdjustPattern() { $pos = QRUtil::getPatternPosition( $this->typeNumber ); @@ -266,7 +266,7 @@ function setupPositionAdjustPattern() { } } - function setupPositionProbePattern( $row, $col ) { + public function setupPositionProbePattern( $row, $col ) { for ( $r = -1; $r <= 7; $r++ ) { @@ -285,7 +285,7 @@ function setupPositionProbePattern( $row, $col ) { } } - function setupTimingPattern() { + public function setupTimingPattern() { for ( $i = 8; $i < $this->moduleCount - 8; $i++ ) { @@ -298,7 +298,7 @@ function setupTimingPattern() { } } - function setupTypeNumber( $test ) { + public function setupTypeNumber( $test ) { $bits = QRUtil::getBCHTypeNumber( $this->typeNumber ); @@ -309,7 +309,7 @@ function setupTypeNumber( $test ) { } } - function setupTypeInfo( $test, $maskPattern ) { + public function setupTypeInfo( $test, $maskPattern ) { $data = ( $this->errorCorrectLevel << 3 ) | $maskPattern; $bits = QRUtil::getBCHTypeInfo( $data ); @@ -338,7 +338,7 @@ function setupTypeInfo( $test, $maskPattern ) { $this->modules[ $this->moduleCount - 8 ][8] = ! $test; } - function createData( $typeNumber, $errorCorrectLevel, $dataArray ) { + public function createData( $typeNumber, $errorCorrectLevel, $dataArray ) { $rsBlocks = QRRSBlock::getRSBlocks( $typeNumber, $errorCorrectLevel ); @@ -359,12 +359,12 @@ function createData( $typeNumber, $errorCorrectLevel, $dataArray ) { if ( $buffer->getLengthInBits() > $totalDataCount * 8 ) { trigger_error( - 'code length overflow. (' + 'code length overflow. (' . $buffer->getLengthInBits() . '>' . $totalDataCount * 8 . ')', - E_USER_ERROR + E_USER_ERROR ); } @@ -401,7 +401,7 @@ function createData( $typeNumber, $errorCorrectLevel, $dataArray ) { * * @return array */ - function createBytes( &$buffer, &$rsBlocks ) { + public function createBytes( &$buffer, &$rsBlocks ) { $offset = 0; @@ -469,7 +469,7 @@ function createBytes( &$buffer, &$rsBlocks ) { return $data; } - static function getMinimumQRCode( $data, $errorCorrectLevel ) { + public static function getMinimumQRCode( $data, $errorCorrectLevel ) { $mode = QRUtil::getMode( $data ); @@ -495,7 +495,7 @@ static function getMinimumQRCode( $data, $errorCorrectLevel ) { // added $fg (foreground), $bg (background), and $bgtrans (use transparent bg) parameters // also added some simple error checking on parameters // updated 2015.07.27 ~ DoktorJ - function createImage( $size = 2, $margin = 2, $fg = 0x000000, $bg = 0xFFFFFF, $bgtrans = false ) { + public function createImage( $size = 2, $margin = 2, $fg = 0x000000, $bg = 0xFFFFFF, $bgtrans = false ) { // size/margin EC if ( ! is_numeric( $size ) ) { @@ -543,12 +543,12 @@ function createImage( $size = 2, $margin = 2, $fg = 0x000000, $bg = 0xFFFFFF, $b // update $black to $fgc imagefilledrectangle( - $image, - $margin + $c * $size, - $margin + $r * $size, - $margin + ( $c + 1 ) * $size - 1, - $margin + ( $r + 1 ) * $size - 1, - $fgc + $image, + $margin + $c * $size, + $margin + $r * $size, + $margin + ( $c + 1 ) * $size - 1, + $margin + ( $r + 1 ) * $size - 1, + $fgc ); } } @@ -557,7 +557,7 @@ function createImage( $size = 2, $margin = 2, $fg = 0x000000, $bg = 0xFFFFFF, $b return $image; } - function printHTML( $size = '2px' ) { + public function printHTML( $size = '2px' ) { $style = 'border-style:none;border-collapse:collapse;margin:0px;padding:0px;'; @@ -600,86 +600,86 @@ public function printSVG( $size = 2 ) { //--------------------------------------------------------------- define( - 'QR_G15', - ( 1 << 10 ) | ( 1 << 8 ) | ( 1 << 5 ) + 'QR_G15', + ( 1 << 10 ) | ( 1 << 8 ) | ( 1 << 5 ) | ( 1 << 4 ) | ( 1 << 2 ) | ( 1 << 1 ) | ( 1 << 0 ) ); define( - 'QR_G18', - ( 1 << 12 ) | ( 1 << 11 ) | ( 1 << 10 ) + 'QR_G18', + ( 1 << 12 ) | ( 1 << 11 ) | ( 1 << 10 ) | ( 1 << 9 ) | ( 1 << 8 ) | ( 1 << 5 ) | ( 1 << 2 ) | ( 1 << 0 ) ); define( - 'QR_G15_MASK', - ( 1 << 14 ) | ( 1 << 12 ) | ( 1 << 10 ) + 'QR_G15_MASK', + ( 1 << 14 ) | ( 1 << 12 ) | ( 1 << 10 ) | ( 1 << 4 ) | ( 1 << 1 ) ); class QRUtil { - static $QR_MAX_LENGTH = array( - array( array( 41, 25, 17, 10 ), array( 34, 20, 14, 8 ), array( 27, 16, 11, 7 ), array( 17, 10, 7, 4 ) ), - array( array( 77, 47, 32, 20 ), array( 63, 38, 26, 16 ), array( 48, 29, 20, 12 ), array( 34, 20, 14, 8 ) ), - array( array( 127, 77, 53, 32 ), array( 101, 61, 42, 26 ), array( 77, 47, 32, 20 ), array( 58, 35, 24, 15 ) ), - array( array( 187, 114, 78, 48 ), array( 149, 90, 62, 38 ), array( 111, 67, 46, 28 ), array( 82, 50, 34, 21 ) ), - array( array( 255, 154, 106, 65 ), array( 202, 122, 84, 52 ), array( 144, 87, 60, 37 ), array( 106, 64, 44, 27 ) ), - array( array( 322, 195, 134, 82 ), array( 255, 154, 106, 65 ), array( 178, 108, 74, 45 ), array( 139, 84, 58, 36 ) ), - array( array( 370, 224, 154, 95 ), array( 293, 178, 122, 75 ), array( 207, 125, 86, 53 ), array( 154, 93, 64, 39 ) ), - array( array( 461, 279, 192, 118 ), array( 365, 221, 152, 93 ), array( 259, 157, 108, 66 ), array( 202, 122, 84, 52 ) ), - array( array( 552, 335, 230, 141 ), array( 432, 262, 180, 111 ), array( 312, 189, 130, 80 ), array( 235, 143, 98, 60 ) ), - array( array( 652, 395, 271, 167 ), array( 513, 311, 213, 131 ), array( 364, 221, 151, 93 ), array( 288, 174, 119, 74 ) ), - ); - - static $QR_PATTERN_POSITION_TABLE = array( - array(), - array( 6, 18 ), - array( 6, 22 ), - array( 6, 26 ), - array( 6, 30 ), - array( 6, 34 ), - array( 6, 22, 38 ), - array( 6, 24, 42 ), - array( 6, 26, 46 ), - array( 6, 28, 50 ), - array( 6, 30, 54 ), - array( 6, 32, 58 ), - array( 6, 34, 62 ), - array( 6, 26, 46, 66 ), - array( 6, 26, 48, 70 ), - array( 6, 26, 50, 74 ), - array( 6, 30, 54, 78 ), - array( 6, 30, 56, 82 ), - array( 6, 30, 58, 86 ), - array( 6, 34, 62, 90 ), - array( 6, 28, 50, 72, 94 ), - array( 6, 26, 50, 74, 98 ), - array( 6, 30, 54, 78, 102 ), - array( 6, 28, 54, 80, 106 ), - array( 6, 32, 58, 84, 110 ), - array( 6, 30, 58, 86, 114 ), - array( 6, 34, 62, 90, 118 ), - array( 6, 26, 50, 74, 98, 122 ), - array( 6, 30, 54, 78, 102, 126 ), - array( 6, 26, 52, 78, 104, 130 ), - array( 6, 30, 56, 82, 108, 134 ), - array( 6, 34, 60, 86, 112, 138 ), - array( 6, 30, 58, 86, 114, 142 ), - array( 6, 34, 62, 90, 118, 146 ), - array( 6, 30, 54, 78, 102, 126, 150 ), - array( 6, 24, 50, 76, 102, 128, 154 ), - array( 6, 28, 54, 80, 106, 132, 158 ), - array( 6, 32, 58, 84, 110, 136, 162 ), - array( 6, 26, 54, 82, 110, 138, 166 ), - array( 6, 30, 58, 86, 114, 142, 170 ), - ); - - static function getPatternPosition( $typeNumber ) { + public static $QR_MAX_LENGTH = [ + [ [ 41, 25, 17, 10 ], [ 34, 20, 14, 8 ], [ 27, 16, 11, 7 ], [ 17, 10, 7, 4 ] ], + [ [ 77, 47, 32, 20 ], [ 63, 38, 26, 16 ], [ 48, 29, 20, 12 ], [ 34, 20, 14, 8 ] ], + [ [ 127, 77, 53, 32 ], [ 101, 61, 42, 26 ], [ 77, 47, 32, 20 ], [ 58, 35, 24, 15 ] ], + [ [ 187, 114, 78, 48 ], [ 149, 90, 62, 38 ], [ 111, 67, 46, 28 ], [ 82, 50, 34, 21 ] ], + [ [ 255, 154, 106, 65 ], [ 202, 122, 84, 52 ], [ 144, 87, 60, 37 ], [ 106, 64, 44, 27 ] ], + [ [ 322, 195, 134, 82 ], [ 255, 154, 106, 65 ], [ 178, 108, 74, 45 ], [ 139, 84, 58, 36 ] ], + [ [ 370, 224, 154, 95 ], [ 293, 178, 122, 75 ], [ 207, 125, 86, 53 ], [ 154, 93, 64, 39 ] ], + [ [ 461, 279, 192, 118 ], [ 365, 221, 152, 93 ], [ 259, 157, 108, 66 ], [ 202, 122, 84, 52 ] ], + [ [ 552, 335, 230, 141 ], [ 432, 262, 180, 111 ], [ 312, 189, 130, 80 ], [ 235, 143, 98, 60 ] ], + [ [ 652, 395, 271, 167 ], [ 513, 311, 213, 131 ], [ 364, 221, 151, 93 ], [ 288, 174, 119, 74 ] ], + ]; + + public static $QR_PATTERN_POSITION_TABLE = [ + [], + [ 6, 18 ], + [ 6, 22 ], + [ 6, 26 ], + [ 6, 30 ], + [ 6, 34 ], + [ 6, 22, 38 ], + [ 6, 24, 42 ], + [ 6, 26, 46 ], + [ 6, 28, 50 ], + [ 6, 30, 54 ], + [ 6, 32, 58 ], + [ 6, 34, 62 ], + [ 6, 26, 46, 66 ], + [ 6, 26, 48, 70 ], + [ 6, 26, 50, 74 ], + [ 6, 30, 54, 78 ], + [ 6, 30, 56, 82 ], + [ 6, 30, 58, 86 ], + [ 6, 34, 62, 90 ], + [ 6, 28, 50, 72, 94 ], + [ 6, 26, 50, 74, 98 ], + [ 6, 30, 54, 78, 102 ], + [ 6, 28, 54, 80, 106 ], + [ 6, 32, 58, 84, 110 ], + [ 6, 30, 58, 86, 114 ], + [ 6, 34, 62, 90, 118 ], + [ 6, 26, 50, 74, 98, 122 ], + [ 6, 30, 54, 78, 102, 126 ], + [ 6, 26, 52, 78, 104, 130 ], + [ 6, 30, 56, 82, 108, 134 ], + [ 6, 34, 60, 86, 112, 138 ], + [ 6, 30, 58, 86, 114, 142 ], + [ 6, 34, 62, 90, 118, 146 ], + [ 6, 30, 54, 78, 102, 126, 150 ], + [ 6, 24, 50, 76, 102, 128, 154 ], + [ 6, 28, 54, 80, 106, 132, 158 ], + [ 6, 32, 58, 84, 110, 136, 162 ], + [ 6, 26, 54, 82, 110, 138, 166 ], + [ 6, 30, 58, 86, 114, 142, 170 ], + ]; + + public static function getPatternPosition( $typeNumber ) { return self::$QR_PATTERN_POSITION_TABLE[ $typeNumber - 1 ]; } - static function getMaxLength( $typeNumber, $mode, $errorCorrectLevel ) { + public static function getMaxLength( $typeNumber, $mode, $errorCorrectLevel ) { $t = $typeNumber - 1; $e = 0; @@ -722,18 +722,18 @@ static function getMaxLength( $typeNumber, $mode, $errorCorrectLevel ) { return self::$QR_MAX_LENGTH[ $t ][ $e ][ $m ]; } - static function getErrorCorrectPolynomial( $errorCorrectLength ) { + public static function getErrorCorrectPolynomial( $errorCorrectLength ) { - $a = new QRPolynomial( array( 1 ) ); + $a = new QRPolynomial( [ 1 ] ); for ( $i = 0; $i < $errorCorrectLength; $i++ ) { - $a = $a->multiply( new QRPolynomial( array( 1, QRMath::gexp( $i ) ) ) ); + $a = $a->multiply( new QRPolynomial( [ 1, QRMath::gexp( $i ) ] ) ); } return $a; } - static function getMask( $maskPattern, $i, $j ) { + public static function getMask( $maskPattern, $i, $j ) { switch ( $maskPattern ) { @@ -764,7 +764,7 @@ static function getMask( $maskPattern, $i, $j ) { * * @return float|int */ - static function getLostPoint( $qrCode ) { + public static function getLostPoint( $qrCode ) { $moduleCount = $qrCode->getModuleCount(); @@ -874,7 +874,7 @@ static function getLostPoint( $qrCode ) { return $lostPoint; } - static function getMode( $s ) { + public static function getMode( $s ) { if ( self::isAlphaNum( $s ) ) { if ( self::isNumber( $s ) ) { return QR_MODE_NUMBER; @@ -887,7 +887,7 @@ static function getMode( $s ) { } } - static function isNumber( $s ) { + public static function isNumber( $s ) { for ( $i = 0; $i < strlen( $s ); $i++ ) { $c = ord( $s[ $i ] ); if ( ! ( self::toCharCode( '0' ) <= $c && $c <= self::toCharCode( '9' ) ) ) { @@ -897,7 +897,7 @@ static function isNumber( $s ) { return true; } - static function isAlphaNum( $s ) { + public static function isAlphaNum( $s ) { for ( $i = 0; $i < strlen( $s ); $i++ ) { $c = ord( $s[ $i ] ); if ( ! ( self::toCharCode( '0' ) <= $c && $c <= self::toCharCode( '9' ) ) @@ -909,7 +909,7 @@ static function isAlphaNum( $s ) { return true; } - static function isKanji( $s ) { + public static function isKanji( $s ) { $data = $s; @@ -933,11 +933,11 @@ static function isKanji( $s ) { return true; } - static function toCharCode( $s ) { + public static function toCharCode( $s ) { return ord( $s[0] ); } - static function getBCHTypeInfo( $data ) { + public static function getBCHTypeInfo( $data ) { $d = $data << 10; while ( self::getBCHDigit( $d ) - self::getBCHDigit( QR_G15 ) >= 0 ) { $d ^= ( QR_G15 << ( self::getBCHDigit( $d ) - self::getBCHDigit( QR_G15 ) ) ); @@ -945,7 +945,7 @@ static function getBCHTypeInfo( $data ) { return ( ( $data << 10 ) | $d ) ^ QR_G15_MASK; } - static function getBCHTypeNumber( $data ) { + public static function getBCHTypeNumber( $data ) { $d = $data << 12; while ( self::getBCHDigit( $d ) - self::getBCHDigit( QR_G18 ) >= 0 ) { $d ^= ( QR_G18 << ( self::getBCHDigit( $d ) - self::getBCHDigit( QR_G18 ) ) ); @@ -953,7 +953,7 @@ static function getBCHTypeNumber( $data ) { return ( $data << 12 ) | $d; } - static function getBCHDigit( $data ) { + public static function getBCHDigit( $data ) { $digit = 0; @@ -972,10 +972,10 @@ static function getBCHDigit( $data ) { class QRRSBlock { - var $totalCount; - var $dataCount; + public $totalCount; + public $dataCount; - static $QR_RS_BLOCK_TABLE = array( + public static $QR_RS_BLOCK_TABLE = [ // L // M @@ -983,266 +983,266 @@ class QRRSBlock { // H // 1 - array( 1, 26, 19 ), - array( 1, 26, 16 ), - array( 1, 26, 13 ), - array( 1, 26, 9 ), + [ 1, 26, 19 ], + [ 1, 26, 16 ], + [ 1, 26, 13 ], + [ 1, 26, 9 ], // 2 - array( 1, 44, 34 ), - array( 1, 44, 28 ), - array( 1, 44, 22 ), - array( 1, 44, 16 ), + [ 1, 44, 34 ], + [ 1, 44, 28 ], + [ 1, 44, 22 ], + [ 1, 44, 16 ], // 3 - array( 1, 70, 55 ), - array( 1, 70, 44 ), - array( 2, 35, 17 ), - array( 2, 35, 13 ), + [ 1, 70, 55 ], + [ 1, 70, 44 ], + [ 2, 35, 17 ], + [ 2, 35, 13 ], // 4 - array( 1, 100, 80 ), - array( 2, 50, 32 ), - array( 2, 50, 24 ), - array( 4, 25, 9 ), + [ 1, 100, 80 ], + [ 2, 50, 32 ], + [ 2, 50, 24 ], + [ 4, 25, 9 ], // 5 - array( 1, 134, 108 ), - array( 2, 67, 43 ), - array( 2, 33, 15, 2, 34, 16 ), - array( 2, 33, 11, 2, 34, 12 ), + [ 1, 134, 108 ], + [ 2, 67, 43 ], + [ 2, 33, 15, 2, 34, 16 ], + [ 2, 33, 11, 2, 34, 12 ], // 6 - array( 2, 86, 68 ), - array( 4, 43, 27 ), - array( 4, 43, 19 ), - array( 4, 43, 15 ), + [ 2, 86, 68 ], + [ 4, 43, 27 ], + [ 4, 43, 19 ], + [ 4, 43, 15 ], // 7 - array( 2, 98, 78 ), - array( 4, 49, 31 ), - array( 2, 32, 14, 4, 33, 15 ), - array( 4, 39, 13, 1, 40, 14 ), + [ 2, 98, 78 ], + [ 4, 49, 31 ], + [ 2, 32, 14, 4, 33, 15 ], + [ 4, 39, 13, 1, 40, 14 ], // 8 - array( 2, 121, 97 ), - array( 2, 60, 38, 2, 61, 39 ), - array( 4, 40, 18, 2, 41, 19 ), - array( 4, 40, 14, 2, 41, 15 ), + [ 2, 121, 97 ], + [ 2, 60, 38, 2, 61, 39 ], + [ 4, 40, 18, 2, 41, 19 ], + [ 4, 40, 14, 2, 41, 15 ], // 9 - array( 2, 146, 116 ), - array( 3, 58, 36, 2, 59, 37 ), - array( 4, 36, 16, 4, 37, 17 ), - array( 4, 36, 12, 4, 37, 13 ), + [ 2, 146, 116 ], + [ 3, 58, 36, 2, 59, 37 ], + [ 4, 36, 16, 4, 37, 17 ], + [ 4, 36, 12, 4, 37, 13 ], // 10 - array( 2, 86, 68, 2, 87, 69 ), - array( 4, 69, 43, 1, 70, 44 ), - array( 6, 43, 19, 2, 44, 20 ), - array( 6, 43, 15, 2, 44, 16 ), + [ 2, 86, 68, 2, 87, 69 ], + [ 4, 69, 43, 1, 70, 44 ], + [ 6, 43, 19, 2, 44, 20 ], + [ 6, 43, 15, 2, 44, 16 ], // 11 - array( 4, 101, 81 ), - array( 1, 80, 50, 4, 81, 51 ), - array( 4, 50, 22, 4, 51, 23 ), - array( 3, 36, 12, 8, 37, 13 ), + [ 4, 101, 81 ], + [ 1, 80, 50, 4, 81, 51 ], + [ 4, 50, 22, 4, 51, 23 ], + [ 3, 36, 12, 8, 37, 13 ], // 12 - array( 2, 116, 92, 2, 117, 93 ), - array( 6, 58, 36, 2, 59, 37 ), - array( 4, 46, 20, 6, 47, 21 ), - array( 7, 42, 14, 4, 43, 15 ), + [ 2, 116, 92, 2, 117, 93 ], + [ 6, 58, 36, 2, 59, 37 ], + [ 4, 46, 20, 6, 47, 21 ], + [ 7, 42, 14, 4, 43, 15 ], // 13 - array( 4, 133, 107 ), - array( 8, 59, 37, 1, 60, 38 ), - array( 8, 44, 20, 4, 45, 21 ), - array( 12, 33, 11, 4, 34, 12 ), + [ 4, 133, 107 ], + [ 8, 59, 37, 1, 60, 38 ], + [ 8, 44, 20, 4, 45, 21 ], + [ 12, 33, 11, 4, 34, 12 ], // 14 - array( 3, 145, 115, 1, 146, 116 ), - array( 4, 64, 40, 5, 65, 41 ), - array( 11, 36, 16, 5, 37, 17 ), - array( 11, 36, 12, 5, 37, 13 ), + [ 3, 145, 115, 1, 146, 116 ], + [ 4, 64, 40, 5, 65, 41 ], + [ 11, 36, 16, 5, 37, 17 ], + [ 11, 36, 12, 5, 37, 13 ], // 15 - array( 5, 109, 87, 1, 110, 88 ), - array( 5, 65, 41, 5, 66, 42 ), - array( 5, 54, 24, 7, 55, 25 ), - array( 11, 36, 12, 7, 37, 13 ), + [ 5, 109, 87, 1, 110, 88 ], + [ 5, 65, 41, 5, 66, 42 ], + [ 5, 54, 24, 7, 55, 25 ], + [ 11, 36, 12, 7, 37, 13 ], // 16 - array( 5, 122, 98, 1, 123, 99 ), - array( 7, 73, 45, 3, 74, 46 ), - array( 15, 43, 19, 2, 44, 20 ), - array( 3, 45, 15, 13, 46, 16 ), + [ 5, 122, 98, 1, 123, 99 ], + [ 7, 73, 45, 3, 74, 46 ], + [ 15, 43, 19, 2, 44, 20 ], + [ 3, 45, 15, 13, 46, 16 ], // 17 - array( 1, 135, 107, 5, 136, 108 ), - array( 10, 74, 46, 1, 75, 47 ), - array( 1, 50, 22, 15, 51, 23 ), - array( 2, 42, 14, 17, 43, 15 ), + [ 1, 135, 107, 5, 136, 108 ], + [ 10, 74, 46, 1, 75, 47 ], + [ 1, 50, 22, 15, 51, 23 ], + [ 2, 42, 14, 17, 43, 15 ], // 18 - array( 5, 150, 120, 1, 151, 121 ), - array( 9, 69, 43, 4, 70, 44 ), - array( 17, 50, 22, 1, 51, 23 ), - array( 2, 42, 14, 19, 43, 15 ), + [ 5, 150, 120, 1, 151, 121 ], + [ 9, 69, 43, 4, 70, 44 ], + [ 17, 50, 22, 1, 51, 23 ], + [ 2, 42, 14, 19, 43, 15 ], // 19 - array( 3, 141, 113, 4, 142, 114 ), - array( 3, 70, 44, 11, 71, 45 ), - array( 17, 47, 21, 4, 48, 22 ), - array( 9, 39, 13, 16, 40, 14 ), + [ 3, 141, 113, 4, 142, 114 ], + [ 3, 70, 44, 11, 71, 45 ], + [ 17, 47, 21, 4, 48, 22 ], + [ 9, 39, 13, 16, 40, 14 ], // 20 - array( 3, 135, 107, 5, 136, 108 ), - array( 3, 67, 41, 13, 68, 42 ), - array( 15, 54, 24, 5, 55, 25 ), - array( 15, 43, 15, 10, 44, 16 ), + [ 3, 135, 107, 5, 136, 108 ], + [ 3, 67, 41, 13, 68, 42 ], + [ 15, 54, 24, 5, 55, 25 ], + [ 15, 43, 15, 10, 44, 16 ], // 21 - array( 4, 144, 116, 4, 145, 117 ), - array( 17, 68, 42 ), - array( 17, 50, 22, 6, 51, 23 ), - array( 19, 46, 16, 6, 47, 17 ), + [ 4, 144, 116, 4, 145, 117 ], + [ 17, 68, 42 ], + [ 17, 50, 22, 6, 51, 23 ], + [ 19, 46, 16, 6, 47, 17 ], // 22 - array( 2, 139, 111, 7, 140, 112 ), - array( 17, 74, 46 ), - array( 7, 54, 24, 16, 55, 25 ), - array( 34, 37, 13 ), + [ 2, 139, 111, 7, 140, 112 ], + [ 17, 74, 46 ], + [ 7, 54, 24, 16, 55, 25 ], + [ 34, 37, 13 ], // 23 - array( 4, 151, 121, 5, 152, 122 ), - array( 4, 75, 47, 14, 76, 48 ), - array( 11, 54, 24, 14, 55, 25 ), - array( 16, 45, 15, 14, 46, 16 ), + [ 4, 151, 121, 5, 152, 122 ], + [ 4, 75, 47, 14, 76, 48 ], + [ 11, 54, 24, 14, 55, 25 ], + [ 16, 45, 15, 14, 46, 16 ], // 24 - array( 6, 147, 117, 4, 148, 118 ), - array( 6, 73, 45, 14, 74, 46 ), - array( 11, 54, 24, 16, 55, 25 ), - array( 30, 46, 16, 2, 47, 17 ), + [ 6, 147, 117, 4, 148, 118 ], + [ 6, 73, 45, 14, 74, 46 ], + [ 11, 54, 24, 16, 55, 25 ], + [ 30, 46, 16, 2, 47, 17 ], // 25 - array( 8, 132, 106, 4, 133, 107 ), - array( 8, 75, 47, 13, 76, 48 ), - array( 7, 54, 24, 22, 55, 25 ), - array( 22, 45, 15, 13, 46, 16 ), + [ 8, 132, 106, 4, 133, 107 ], + [ 8, 75, 47, 13, 76, 48 ], + [ 7, 54, 24, 22, 55, 25 ], + [ 22, 45, 15, 13, 46, 16 ], // 26 - array( 10, 142, 114, 2, 143, 115 ), - array( 19, 74, 46, 4, 75, 47 ), - array( 28, 50, 22, 6, 51, 23 ), - array( 33, 46, 16, 4, 47, 17 ), + [ 10, 142, 114, 2, 143, 115 ], + [ 19, 74, 46, 4, 75, 47 ], + [ 28, 50, 22, 6, 51, 23 ], + [ 33, 46, 16, 4, 47, 17 ], // 27 - array( 8, 152, 122, 4, 153, 123 ), - array( 22, 73, 45, 3, 74, 46 ), - array( 8, 53, 23, 26, 54, 24 ), - array( 12, 45, 15, 28, 46, 16 ), + [ 8, 152, 122, 4, 153, 123 ], + [ 22, 73, 45, 3, 74, 46 ], + [ 8, 53, 23, 26, 54, 24 ], + [ 12, 45, 15, 28, 46, 16 ], // 28 - array( 3, 147, 117, 10, 148, 118 ), - array( 3, 73, 45, 23, 74, 46 ), - array( 4, 54, 24, 31, 55, 25 ), - array( 11, 45, 15, 31, 46, 16 ), + [ 3, 147, 117, 10, 148, 118 ], + [ 3, 73, 45, 23, 74, 46 ], + [ 4, 54, 24, 31, 55, 25 ], + [ 11, 45, 15, 31, 46, 16 ], // 29 - array( 7, 146, 116, 7, 147, 117 ), - array( 21, 73, 45, 7, 74, 46 ), - array( 1, 53, 23, 37, 54, 24 ), - array( 19, 45, 15, 26, 46, 16 ), + [ 7, 146, 116, 7, 147, 117 ], + [ 21, 73, 45, 7, 74, 46 ], + [ 1, 53, 23, 37, 54, 24 ], + [ 19, 45, 15, 26, 46, 16 ], // 30 - array( 5, 145, 115, 10, 146, 116 ), - array( 19, 75, 47, 10, 76, 48 ), - array( 15, 54, 24, 25, 55, 25 ), - array( 23, 45, 15, 25, 46, 16 ), + [ 5, 145, 115, 10, 146, 116 ], + [ 19, 75, 47, 10, 76, 48 ], + [ 15, 54, 24, 25, 55, 25 ], + [ 23, 45, 15, 25, 46, 16 ], // 31 - array( 13, 145, 115, 3, 146, 116 ), - array( 2, 74, 46, 29, 75, 47 ), - array( 42, 54, 24, 1, 55, 25 ), - array( 23, 45, 15, 28, 46, 16 ), + [ 13, 145, 115, 3, 146, 116 ], + [ 2, 74, 46, 29, 75, 47 ], + [ 42, 54, 24, 1, 55, 25 ], + [ 23, 45, 15, 28, 46, 16 ], // 32 - array( 17, 145, 115 ), - array( 10, 74, 46, 23, 75, 47 ), - array( 10, 54, 24, 35, 55, 25 ), - array( 19, 45, 15, 35, 46, 16 ), + [ 17, 145, 115 ], + [ 10, 74, 46, 23, 75, 47 ], + [ 10, 54, 24, 35, 55, 25 ], + [ 19, 45, 15, 35, 46, 16 ], // 33 - array( 17, 145, 115, 1, 146, 116 ), - array( 14, 74, 46, 21, 75, 47 ), - array( 29, 54, 24, 19, 55, 25 ), - array( 11, 45, 15, 46, 46, 16 ), + [ 17, 145, 115, 1, 146, 116 ], + [ 14, 74, 46, 21, 75, 47 ], + [ 29, 54, 24, 19, 55, 25 ], + [ 11, 45, 15, 46, 46, 16 ], // 34 - array( 13, 145, 115, 6, 146, 116 ), - array( 14, 74, 46, 23, 75, 47 ), - array( 44, 54, 24, 7, 55, 25 ), - array( 59, 46, 16, 1, 47, 17 ), + [ 13, 145, 115, 6, 146, 116 ], + [ 14, 74, 46, 23, 75, 47 ], + [ 44, 54, 24, 7, 55, 25 ], + [ 59, 46, 16, 1, 47, 17 ], // 35 - array( 12, 151, 121, 7, 152, 122 ), - array( 12, 75, 47, 26, 76, 48 ), - array( 39, 54, 24, 14, 55, 25 ), - array( 22, 45, 15, 41, 46, 16 ), + [ 12, 151, 121, 7, 152, 122 ], + [ 12, 75, 47, 26, 76, 48 ], + [ 39, 54, 24, 14, 55, 25 ], + [ 22, 45, 15, 41, 46, 16 ], // 36 - array( 6, 151, 121, 14, 152, 122 ), - array( 6, 75, 47, 34, 76, 48 ), - array( 46, 54, 24, 10, 55, 25 ), - array( 2, 45, 15, 64, 46, 16 ), + [ 6, 151, 121, 14, 152, 122 ], + [ 6, 75, 47, 34, 76, 48 ], + [ 46, 54, 24, 10, 55, 25 ], + [ 2, 45, 15, 64, 46, 16 ], // 37 - array( 17, 152, 122, 4, 153, 123 ), - array( 29, 74, 46, 14, 75, 47 ), - array( 49, 54, 24, 10, 55, 25 ), - array( 24, 45, 15, 46, 46, 16 ), + [ 17, 152, 122, 4, 153, 123 ], + [ 29, 74, 46, 14, 75, 47 ], + [ 49, 54, 24, 10, 55, 25 ], + [ 24, 45, 15, 46, 46, 16 ], // 38 - array( 4, 152, 122, 18, 153, 123 ), - array( 13, 74, 46, 32, 75, 47 ), - array( 48, 54, 24, 14, 55, 25 ), - array( 42, 45, 15, 32, 46, 16 ), + [ 4, 152, 122, 18, 153, 123 ], + [ 13, 74, 46, 32, 75, 47 ], + [ 48, 54, 24, 14, 55, 25 ], + [ 42, 45, 15, 32, 46, 16 ], // 39 - array( 20, 147, 117, 4, 148, 118 ), - array( 40, 75, 47, 7, 76, 48 ), - array( 43, 54, 24, 22, 55, 25 ), - array( 10, 45, 15, 67, 46, 16 ), + [ 20, 147, 117, 4, 148, 118 ], + [ 40, 75, 47, 7, 76, 48 ], + [ 43, 54, 24, 22, 55, 25 ], + [ 10, 45, 15, 67, 46, 16 ], // 40 - array( 19, 148, 118, 6, 149, 119 ), - array( 18, 75, 47, 31, 76, 48 ), - array( 34, 54, 24, 34, 55, 25 ), - array( 20, 45, 15, 61, 46, 16 ), + [ 19, 148, 118, 6, 149, 119 ], + [ 18, 75, 47, 31, 76, 48 ], + [ 34, 54, 24, 34, 55, 25 ], + [ 20, 45, 15, 61, 46, 16 ], - ); + ]; - function __construct( $totalCount, $dataCount ) { + public function __construct( $totalCount, $dataCount ) { $this->totalCount = $totalCount; $this->dataCount = $dataCount; } - function getDataCount() { + public function getDataCount() { return $this->dataCount; } - function getTotalCount() { + public function getTotalCount() { return $this->totalCount; } - static function getRSBlocks( $typeNumber, $errorCorrectLevel ) { + public static function getRSBlocks( $typeNumber, $errorCorrectLevel ) { $rsBlock = self::getRsBlockTable( $typeNumber, $errorCorrectLevel ); $length = count( $rsBlock ) / 3; - $list = array(); + $list = []; for ( $i = 0; $i < $length; $i++ ) { @@ -1258,7 +1258,7 @@ static function getRSBlocks( $typeNumber, $errorCorrectLevel ) { return $list; } - static function getRsBlockTable( $typeNumber, $errorCorrectLevel ) { + public static function getRsBlockTable( $typeNumber, $errorCorrectLevel ) { switch ( $errorCorrectLevel ) { case QR_ERROR_CORRECT_LEVEL_L: @@ -1281,11 +1281,11 @@ static function getRsBlockTable( $typeNumber, $errorCorrectLevel ) { class QRNumber extends QRData { - function __construct( $data ) { + public function __construct( $data ) { parent::__construct( QR_MODE_NUMBER, $data ); } - function write( &$buffer ) { + public function write( &$buffer ) { $data = $this->getData(); @@ -1309,7 +1309,7 @@ function write( &$buffer ) { } } - static function parseInt( $s ) { + public static function parseInt( $s ) { $num = 0; for ( $i = 0; $i < strlen( $s ); $i++ ) { @@ -1318,7 +1318,7 @@ static function parseInt( $s ) { return $num; } - static function parseIntAt( $c ) { + public static function parseIntAt( $c ) { if ( QRUtil::toCharCode( '0' ) <= $c && $c <= QRUtil::toCharCode( '9' ) ) { return $c - QRUtil::toCharCode( '0' ); @@ -1334,11 +1334,11 @@ static function parseIntAt( $c ) { class QRKanji extends QRData { - function __construct( $data ) { + public function __construct( $data ) { parent::__construct( QR_MODE_KANJI, $data ); } - function write( &$buffer ) { + public function write( &$buffer ) { $data = $this->getData(); @@ -1368,7 +1368,7 @@ function write( &$buffer ) { } } - function getLength() { + public function getLength() { return floor( strlen( $this->getData() ) / 2 ); } } @@ -1379,20 +1379,20 @@ function getLength() { class QRAlphaNum extends QRData { - function __construct( $data ) { + public function __construct( $data ) { parent::__construct( QR_MODE_ALPHA_NUM, $data ); } - function write( &$buffer ) { + public function write( &$buffer ) { $i = 0; $c = $this->getData(); while ( $i + 1 < strlen( $c ) ) { $buffer->put( - self::getCode( ord( $c[ $i ] ) ) * 45 + self::getCode( ord( $c[ $i ] ) ) * 45 + self::getCode( ord( $c[ $i + 1 ] ) ), - 11 + 11 ); $i += 2; } @@ -1402,7 +1402,7 @@ function write( &$buffer ) { } } - static function getCode( $c ) { + public static function getCode( $c ) { if ( QRUtil::toCharCode( '0' ) <= $c && $c <= QRUtil::toCharCode( '9' ) ) { @@ -1443,11 +1443,11 @@ static function getCode( $c ) { class QR8BitByte extends QRData { - function __construct( $data ) { + public function __construct( $data ) { parent::__construct( QR_MODE_8BIT_BYTE, $data ); } - function write( &$buffer ) { + public function write( &$buffer ) { $data = $this->getData(); for ( $i = 0; $i < strlen( $data ); $i++ ) { @@ -1463,36 +1463,36 @@ function write( &$buffer ) { abstract class QRData { - var $mode; + public $mode; - var $data; + public $data; - function __construct( $mode, $data ) { + public function __construct( $mode, $data ) { $this->mode = $mode; $this->data = $data; } - function getMode() { + public function getMode() { return $this->mode; } - function getData() { + public function getData() { return $this->data; } /** * @return int */ - function getLength() { + public function getLength() { return strlen( $this->getData() ); } /** * @param \QRBitBuffer $buffer */ - abstract function write( &$buffer); + abstract public function write( &$buffer); - function getLengthInBits( $type ) { + public function getLengthInBits( $type ) { if ( 1 <= $type && $type < 10 ) { @@ -1555,10 +1555,10 @@ function getLengthInBits( $type ) { class QRMath { - static $QR_MATH_EXP_TABLE = null; - static $QR_MATH_LOG_TABLE = null; + public static $QR_MATH_EXP_TABLE = null; + public static $QR_MATH_LOG_TABLE = null; - static function init() { + public static function init() { self::$QR_MATH_EXP_TABLE = self::createNumArray( 256 ); @@ -1580,15 +1580,15 @@ static function init() { } } - static function createNumArray( $length ) { - $num_array = array(); + public static function createNumArray( $length ) { + $num_array = []; for ( $i = 0; $i < $length; $i++ ) { $num_array[] = 0; } return $num_array; } - static function glog( $n ) { + public static function glog( $n ) { if ( $n < 1 ) { trigger_error( "log($n)", E_USER_ERROR ); @@ -1597,7 +1597,7 @@ static function glog( $n ) { return self::$QR_MATH_LOG_TABLE[ $n ]; } - static function gexp( $n ) { + public static function gexp( $n ) { while ( $n < 0 ) { $n += 255; @@ -1620,9 +1620,9 @@ static function gexp( $n ) { class QRPolynomial { - var $num; + public $num; - function __construct( $num, $shift = 0 ) { + public function __construct( $num, $shift = 0 ) { $offset = 0; @@ -1636,20 +1636,20 @@ function __construct( $num, $shift = 0 ) { } } - function get( $index ) { + public function get( $index ) { return $this->num[ $index ]; } - function getLength() { + public function getLength() { return count( $this->num ); } // PHP5 - function __toString() { + public function __toString() { return $this->toString(); } - function toString() { + public function toString() { $buffer = ''; @@ -1663,7 +1663,7 @@ function toString() { return $buffer; } - function toLogString() { + public function toLogString() { $buffer = ''; @@ -1682,7 +1682,7 @@ function toLogString() { * * @return \QRPolynomial */ - function multiply( $e ) { + public function multiply( $e ) { $num = QRMath::createNumArray( $this->getLength() + $e->getLength() - 1 ); @@ -1702,7 +1702,7 @@ function multiply( $e ) { * * @return $this|\QRPolynomial */ - function mod( $e ) { + public function mod( $e ) { if ( $this->getLength() - $e->getLength() < 0 ) { return $this; @@ -1765,23 +1765,23 @@ function mod( $e ) { class QRBitBuffer { - var $buffer; - var $length; + public $buffer; + public $length; - function __construct() { - $this->buffer = array(); + public function __construct() { + $this->buffer = []; $this->length = 0; } - function getBuffer() { + public function getBuffer() { return $this->buffer; } - function getLengthInBits() { + public function getLengthInBits() { return $this->length; } - function __toString() { + public function __toString() { $buffer = ''; for ( $i = 0; $i < $this->getLengthInBits(); $i++ ) { $buffer .= $this->get( $i ) ? '1' : '0'; @@ -1789,19 +1789,19 @@ function __toString() { return $buffer; } - function get( $index ) { + public function get( $index ) { $bufIndex = (int) floor( $index / 8 ); return ( ( $this->buffer[ $bufIndex ] >> ( 7 - $index % 8 ) ) & 1 ) == 1; } - function put( $num, $length ) { + public function put( $num, $length ) { for ( $i = 0; $i < $length; $i++ ) { $this->putBit( ( ( $num >> ( $length - $i - 1 ) ) & 1 ) == 1 ); } } - function putBit( $bit ) { + public function putBit( $bit ) { $bufIndex = (int) floor( $this->length / 8 ); if ( count( $this->buffer ) <= $bufIndex ) { diff --git a/cli_mail.php b/cli_mail.php index 8ef67d87..e67a5875 100644 --- a/cli_mail.php +++ b/cli_mail.php @@ -92,7 +92,7 @@ function mailRead( $iKlimit = '' ) { return $sEmail; } -$arguments = getopt( 'hd:f:', array( 'fast', 'allowed_senders:', 'extra_allowed_senders:', 'groupid:' ) ); +$arguments = getopt( 'hd:f:', [ 'fast', 'allowed_senders:', 'extra_allowed_senders:', 'groupid:' ] ); if ( ( ! isset( $arguments['groupid'] ) && ! isset( $arguments['d'] ) ) || isset( $arguments['h'] ) ) { help( $argv[0] ); } @@ -140,7 +140,7 @@ function mailRead( $iKlimit = '' ) { $on_behalf_of = '(' . sprintf( /* translators: %s: original email sender name */ __( 'on behalf of %s', 'events-made-easy' ), - $on_behalf_of + $on_behalf_of ) . ')'; } } @@ -170,7 +170,7 @@ function mailRead( $iKlimit = '' ) { exit(); } -$emails = array(); +$emails = []; foreach ( $names_emails as $entry ) { $emails[] = $entry['email']; } @@ -207,10 +207,10 @@ function mailRead( $iKlimit = '' ) { // now create the mailing $mailing_name = "Forwarding mail from $from_email to $replyto_email to group " . $group['name']; -$conditions = array( +$conditions = [ 'eme_genericmail_send_peoplegroups' => $group['group_id'], 'action' => 'genericmail', -); +]; if ( get_option( 'eme_mail_force_from' ) ) { // by setting the from address to the forced address, we avoid the sender name from being changed in eme_queue_mail later on (which is needed in this case, to keep the "on behalf of" diff --git a/eme-actions.php b/eme-actions.php index 14e9c153..8119d6a6 100644 --- a/eme-actions.php +++ b/eme-actions.php @@ -151,7 +151,7 @@ function eme_actions_early_init() { } } else { header( 'Content-type: application/json; charset=utf-8' ); - echo wp_json_encode( array() ); + echo wp_json_encode( [] ); } exit; } @@ -317,21 +317,21 @@ function eme_add_events_locations_link_search( $results, $query ) { } $events = eme_search_events( $query['s'] ); foreach ( $events as $event ) { - $results[] = array( + $results[] = [ 'ID' => $event['event_id'], 'title' => trim( eme_esc_html( strip_tags( $event['event_name'] ) . ' (' . eme_localized_datetime( $event['event_start'], $eme_timezone ) . ')' ) ), 'permalink' => eme_event_url( $event ), 'info' => __( 'Event', 'events-made-easy' ), - ); + ]; } $locations = eme_search_locations( $query['s'] ); foreach ( $locations as $location ) { - $results[] = array( + $results[] = [ 'ID' => $location['location_id'], 'title' => trim( eme_esc_html( strip_tags( $location['location_name'] ) ) ), 'permalink' => eme_location_url( $location ), 'info' => __( 'Location', 'events-made-easy' ), - ); + ]; } return $results; } @@ -363,28 +363,28 @@ function eme_admin_register_scripts() { $locale_file = $eme_plugin_dir . "js/jquery-select2/select2-4.1.0-rc.0/dist/js/i18n/$language.js"; $locale_file_url = $eme_plugin_url . "js/jquery-select2/select2-4.1.0-rc.0/dist/js/i18n/$language.js"; if ( file_exists( $locale_file ) ) { - wp_register_script( 'eme-select2-locale', $locale_file_url, array( 'eme-select2' ), EME_VERSION ); + wp_register_script( 'eme-select2-locale', $locale_file_url, [ 'eme-select2' ], EME_VERSION ); } } # wp_register_script( 'eme-jquery-datatables', $eme_plugin_url."js/jquery-datatables-1.10.20/datatables.min.js",array( 'jquery' ),EME_VERSION); - wp_register_script( 'eme-print', $eme_plugin_url . 'js/jquery.printelement.js', array( 'jquery' ), EME_VERSION ); - wp_register_script( 'eme-jquery-validate', $eme_plugin_url . 'js/jquery-validate-1.19.3/jquery.validate.min.js', array( 'jquery' ), EME_VERSION ); - wp_register_script( 'eme-jquery-jtable', $eme_plugin_url . 'js/jtable-2.5.0/jquery.jtable.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-dialog' ), EME_VERSION ); - wp_register_script( 'eme-jtable-storage', $eme_plugin_url . 'js/jtable-2.5.0/extensions/jquery.jtable.localstorage.js', array( 'eme-jquery-jtable' ), EME_VERSION ); - wp_register_script( 'eme-jtable-search', $eme_plugin_url . 'js/jtable-2.5.0/extensions/jquery.jtable.toolbarsearch.js', array( 'eme-jquery-jtable', 'eme-jtable-storage' ), EME_VERSION ); + wp_register_script( 'eme-print', $eme_plugin_url . 'js/jquery.printelement.js', [ 'jquery' ], EME_VERSION ); + wp_register_script( 'eme-jquery-validate', $eme_plugin_url . 'js/jquery-validate-1.19.3/jquery.validate.min.js', [ 'jquery' ], EME_VERSION ); + wp_register_script( 'eme-jquery-jtable', $eme_plugin_url . 'js/jtable-2.5.0/jquery.jtable.js', [ 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-dialog' ], EME_VERSION ); + wp_register_script( 'eme-jtable-storage', $eme_plugin_url . 'js/jtable-2.5.0/extensions/jquery.jtable.localstorage.js', [ 'eme-jquery-jtable' ], EME_VERSION ); + wp_register_script( 'eme-jtable-search', $eme_plugin_url . 'js/jtable-2.5.0/extensions/jquery.jtable.toolbarsearch.js', [ 'eme-jquery-jtable', 'eme-jtable-storage' ], EME_VERSION ); if ( wp_script_is( 'eme-select2-locale', 'registered' ) ) { - wp_register_script( 'eme-basic', $eme_plugin_url . 'js/eme.js', array( 'jquery', 'eme-select2', 'eme-select2-locale' ), EME_VERSION ); + wp_register_script( 'eme-basic', $eme_plugin_url . 'js/eme.js', [ 'jquery', 'eme-select2', 'eme-select2-locale' ], EME_VERSION ); } else { - wp_register_script( 'eme-basic', $eme_plugin_url . 'js/eme.js', array( 'jquery', 'eme-select2' ), EME_VERSION ); + wp_register_script( 'eme-basic', $eme_plugin_url . 'js/eme.js', [ 'jquery', 'eme-select2' ], EME_VERSION ); } - wp_register_script( 'eme-admin', $eme_plugin_url . 'js/eme_admin.js', array( 'jquery', 'eme-jquery-jtable', 'eme-jtable-storage', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-tabs', 'jquery-ui-sortable', 'eme-jquery-validate', 'eme-print' ), EME_VERSION ); + wp_register_script( 'eme-admin', $eme_plugin_url . 'js/eme_admin.js', [ 'jquery', 'eme-jquery-jtable', 'eme-jtable-storage', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-tabs', 'jquery-ui-sortable', 'eme-jquery-validate', 'eme-print' ], EME_VERSION ); wp_register_style( 'eme-leaflet-css', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.css', EME_VERSION ); - wp_register_script( 'eme-leaflet-maps', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.js', array( 'jquery' ), EME_VERSION, true ); - wp_register_script( 'eme-admin-maps', $eme_plugin_url . 'js/eme_admin_maps.js', array( 'jquery', 'eme-leaflet-maps' ), EME_VERSION, true ); - wp_register_script( 'eme-autocomplete-form', $eme_plugin_url . 'js/eme_autocomplete_form.js', array( 'jquery-ui-autocomplete' ), EME_VERSION ); - wp_register_script( 'eme-options', $eme_plugin_url . 'js/eme_admin_options.js', array( 'jquery' ), EME_VERSION ); - wp_register_script( 'eme-formfields', $eme_plugin_url . 'js/eme_admin_fields.js', array( 'jquery' ), EME_VERSION ); + wp_register_script( 'eme-leaflet-maps', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.js', [ 'jquery' ], EME_VERSION, true ); + wp_register_script( 'eme-admin-maps', $eme_plugin_url . 'js/eme_admin_maps.js', [ 'jquery', 'eme-leaflet-maps' ], EME_VERSION, true ); + wp_register_script( 'eme-autocomplete-form', $eme_plugin_url . 'js/eme_autocomplete_form.js', [ 'jquery-ui-autocomplete' ], EME_VERSION ); + wp_register_script( 'eme-options', $eme_plugin_url . 'js/eme_admin_options.js', [ 'jquery' ], EME_VERSION ); + wp_register_script( 'eme-formfields', $eme_plugin_url . 'js/eme_admin_fields.js', [ 'jquery' ], EME_VERSION ); $locale_code = determine_locale(); $locale_code = preg_replace( '/_/', '-', $locale_code ); @@ -402,9 +402,9 @@ function eme_admin_register_scripts() { } } - wp_register_script( 'eme-rsvp', $eme_plugin_url . 'js/eme_admin_rsvp.js', array( 'eme-autocomplete-form' ), EME_VERSION ); + wp_register_script( 'eme-rsvp', $eme_plugin_url . 'js/eme_admin_rsvp.js', [ 'eme-autocomplete-form' ], EME_VERSION ); wp_register_script( 'eme-sendmails', $eme_plugin_url . 'js/eme_admin_sendmails.js', '', EME_VERSION ); - wp_register_script( 'eme-discounts', $eme_plugin_url . 'js/eme_admin_discounts.js', array( 'eme-jtable-search' ), EME_VERSION ); + wp_register_script( 'eme-discounts', $eme_plugin_url . 'js/eme_admin_discounts.js', [ 'eme-jtable-search' ], EME_VERSION ); wp_register_script( 'eme-countries', $eme_plugin_url . 'js/eme_admin_countries.js', '', EME_VERSION ); wp_register_script( 'eme-people', $eme_plugin_url . 'js/eme_admin_people.js', '', EME_VERSION ); wp_register_script( 'eme-templates', $eme_plugin_url . 'js/eme_admin_templates.js', '', EME_VERSION ); @@ -440,7 +440,7 @@ function eme_register_scripts_orig() { } eme_enqueue_datetimepicker(); - wp_register_script( 'eme-select2', $eme_plugin_url . 'js/jquery-select2/select2-4.1.0-rc.0/dist/js/select2.min.js', array( 'jquery' ), EME_VERSION, $load_js_in_footer ); + wp_register_script( 'eme-select2', $eme_plugin_url . 'js/jquery-select2/select2-4.1.0-rc.0/dist/js/select2.min.js', [ 'jquery' ], EME_VERSION, $load_js_in_footer ); // we enqueue select2 directly and not as a dependance in eme-basic, so people can dequeue it if wanted wp_enqueue_script( 'eme-select2' ); // for english, no translation code is needed) @@ -450,11 +450,11 @@ function eme_register_scripts_orig() { $locale_file = $eme_plugin_dir . "js/jquery-select2/select2-4.1.0-rc.0/dist//js/i18n/$language.js"; $locale_file_url = $eme_plugin_url . "js/jquery-select2/select2-4.1.0-rc.0/dist//js/i18n/$language.js"; if ( file_exists( $locale_file ) ) { - wp_enqueue_script( 'eme-select2-locale', $locale_file_url, array( 'eme-select2' ), EME_VERSION, $load_js_in_footer ); + wp_enqueue_script( 'eme-select2-locale', $locale_file_url, [ 'eme-select2' ], EME_VERSION, $load_js_in_footer ); } } - wp_register_script( 'eme-basic', $eme_plugin_url . 'js/eme.js', array( 'jquery' ), EME_VERSION, $load_js_in_footer ); - $translation_array = array( + wp_register_script( 'eme-basic', $eme_plugin_url . 'js/eme.js', [ 'jquery' ], EME_VERSION, $load_js_in_footer ); + $translation_array = [ 'translate_plugin_url' => $eme_plugin_url, 'translate_ajax_url' => admin_url( 'admin-ajax.php' ), 'translate_selectstate' => __( 'State', 'events-made-easy' ), @@ -469,16 +469,16 @@ function eme_register_scripts_orig() { 'translate_flanguage' => $language, 'translate_fdateformat' => $eme_wp_date_format, 'translate_ftimeformat' => $eme_wp_time_format, - ); + ]; wp_localize_script( 'eme-basic', 'emebasic', $translation_array ); wp_enqueue_script( 'eme-basic' ); if ( get_option( 'eme_use_client_clock' ) && ! isset( $_COOKIE['eme_client_time'] ) ) { // client clock should be executed asap, so load it in the header, and no defer - $translation_array = array( + $translation_array = [ 'translate_ajax_url' => admin_url( 'admin-ajax.php' ), - ); - wp_register_script( 'eme-client_clock_submit', $eme_plugin_url . 'js/client-clock.js', array( 'jquery' ), EME_VERSION ); + ]; + wp_register_script( 'eme-client_clock_submit', $eme_plugin_url . 'js/client-clock.js', [ 'jquery' ], EME_VERSION ); wp_localize_script( 'eme-client_clock_submit', 'emeclock', $translation_array ); wp_enqueue_script( 'eme-client_clock_submit' ); } @@ -486,41 +486,41 @@ function eme_register_scripts_orig() { // the frontend also needs the autocomplete (rsvp form) $search_tables = get_option( 'eme_autocomplete_sources' ); if ( $search_tables != 'none' && is_user_logged_in() ) { - wp_register_script( 'eme-autocomplete-form', $eme_plugin_url . 'js/eme_autocomplete_form.js', array( 'jquery-ui-autocomplete' ), EME_VERSION, $load_js_in_footer ); + wp_register_script( 'eme-autocomplete-form', $eme_plugin_url . 'js/eme_autocomplete_form.js', [ 'jquery-ui-autocomplete' ], EME_VERSION, $load_js_in_footer ); } if ( get_option( 'eme_massmail_popup' ) ) { wp_enqueue_script( 'jquery-ui-dialog' ); } - wp_enqueue_style( 'eme-jquery-ui-css', $eme_plugin_url . 'css/jquery-ui-theme-smoothness-1.11.3/jquery-ui.min.css', array(), EME_VERSION ); - wp_enqueue_style( 'eme-jquery-ui-autocomplete', $eme_plugin_url . 'css/jquery.autocomplete.css', array(), EME_VERSION ); - wp_enqueue_style( 'eme-jquery-select2-css', $eme_plugin_url . 'js/jquery-select2/select2-4.1.0-rc.0/dist/css/select2.min.css', array(), EME_VERSION ); + wp_enqueue_style( 'eme-jquery-ui-css', $eme_plugin_url . 'css/jquery-ui-theme-smoothness-1.11.3/jquery-ui.min.css', [], EME_VERSION ); + wp_enqueue_style( 'eme-jquery-ui-autocomplete', $eme_plugin_url . 'css/jquery.autocomplete.css', [], EME_VERSION ); + wp_enqueue_style( 'eme-jquery-select2-css', $eme_plugin_url . 'js/jquery-select2/select2-4.1.0-rc.0/dist/css/select2.min.css', [], EME_VERSION ); - wp_enqueue_style( 'eme_textsec', $eme_plugin_url . 'css/text-security/text-security-disc.css', array(), EME_VERSION ); - wp_enqueue_style( 'eme_stylesheet', $eme_plugin_url . 'css/eme.css', array(), EME_VERSION ); + wp_enqueue_style( 'eme_textsec', $eme_plugin_url . 'css/text-security/text-security-disc.css', [], EME_VERSION ); + wp_enqueue_style( 'eme_stylesheet', $eme_plugin_url . 'css/eme.css', [], EME_VERSION ); $eme_css_name = get_stylesheet_directory() . '/eme.css'; if ( file_exists( $eme_css_name ) ) { - wp_enqueue_style( 'eme_stylesheet_extra', get_stylesheet_directory_uri() . '/eme.css', 'eme_stylesheet', array(), EME_VERSION ); + wp_enqueue_style( 'eme_stylesheet_extra', get_stylesheet_directory_uri() . '/eme.css', 'eme_stylesheet', [], EME_VERSION ); } if ( get_option( 'eme_map_is_active' ) ) { - wp_enqueue_style( 'eme-leaflet-css', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.css', array(), EME_VERSION ); + wp_enqueue_style( 'eme-leaflet-css', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.css', [], EME_VERSION ); } - wp_register_script( 'eme-leaflet-maps', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.js', array( 'jquery' ), EME_VERSION, true ); - wp_register_script( 'eme-leaflet-gestures', $eme_plugin_url . 'js/leaflet-gesturehandling-1.2.1/leaflet-gesture-handling.min.js', array( 'jquery', 'eme-leaflet-maps' ), EME_VERSION, true ); - wp_register_script( 'eme-leaflet-markercluster', $eme_plugin_url . 'js/leaflet-markercluster-1.4.1/leaflet.markercluster.js', array( 'eme-leaflet-maps' ), EME_VERSION, true ); + wp_register_script( 'eme-leaflet-maps', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.js', [ 'jquery' ], EME_VERSION, true ); + wp_register_script( 'eme-leaflet-gestures', $eme_plugin_url . 'js/leaflet-gesturehandling-1.2.1/leaflet-gesture-handling.min.js', [ 'jquery', 'eme-leaflet-maps' ], EME_VERSION, true ); + wp_register_script( 'eme-leaflet-markercluster', $eme_plugin_url . 'js/leaflet-markercluster-1.4.1/leaflet.markercluster.js', [ 'eme-leaflet-maps' ], EME_VERSION, true ); wp_register_style( 'eme-markercluster-css1', $eme_plugin_url . 'js/leaflet-markercluster-1.4.1/MarkerCluster.css', EME_VERSION, false ); wp_register_style( 'eme-markercluster-css2', $eme_plugin_url . 'js/leaflet-markercluster-1.4.1/MarkerCluster.Default.css', EME_VERSION, false ); wp_register_style( 'eme-gestures-css', $eme_plugin_url . 'js/leaflet-gesturehandling-1.2.1/leaflet-gesture-handling.min.css', EME_VERSION, false ); - wp_register_script( 'eme-location-map', $eme_plugin_url . 'js/eme_location_map.js', array( 'jquery', 'eme-leaflet-maps' ), EME_VERSION, true ); + wp_register_script( 'eme-location-map', $eme_plugin_url . 'js/eme_location_map.js', [ 'jquery', 'eme-leaflet-maps' ], EME_VERSION, true ); if ( get_option( 'eme_recaptcha_for_forms' ) ) { // using explicit rendering of the captcha would allow to capture the widget id and reset it if needed, but we won't use that ... //wp_register_script( 'eme-recaptcha', 'https://www.google.com/recaptcha/api.js?onload=eme_CaptchaCallback&render=explicit', array('eme-basic'), '',true); - wp_register_script( 'eme-recaptcha', 'https://www.google.com/recaptcha/api.js', array( 'eme-basic' ), '', true ); + wp_register_script( 'eme-recaptcha', 'https://www.google.com/recaptcha/api.js', [ 'eme-basic' ], '', true ); } if ( get_option( 'eme_hcaptcha_for_forms' ) ) { - wp_register_script( 'eme-hcaptcha', 'https://js.hcaptcha.com/1/api.js', array( 'eme-basic' ), '', true ); + wp_register_script( 'eme-hcaptcha', 'https://js.hcaptcha.com/1/api.js', [ 'eme-basic' ], '', true ); } } @@ -535,17 +535,17 @@ function eme_register_scripts() { } $language = eme_detect_lang(); - wp_register_script( 'eme-select2', $eme_plugin_url . 'js/jquery-select2/select2-4.1.0-rc.0/dist/js/select2.min.js', array( 'jquery' ), EME_VERSION, $load_js_in_footer ); + wp_register_script( 'eme-select2', $eme_plugin_url . 'js/jquery-select2/select2-4.1.0-rc.0/dist/js/select2.min.js', [ 'jquery' ], EME_VERSION, $load_js_in_footer ); if ( $language != 'en' ) { $eme_plugin_dir = eme_plugin_dir(); $locale_file = $eme_plugin_dir . "js/jquery-select2/select2-4.1.0-rc.0/dist//js/i18n/$language.js"; $locale_file_url = $eme_plugin_url . "js/jquery-select2/select2-4.1.0-rc.0/dist//js/i18n/$language.js"; if ( file_exists( $locale_file ) ) { - wp_register_script( 'eme-select2-locale', $locale_file_url, array( 'eme-select2' ), EME_VERSION, $load_js_in_footer ); + wp_register_script( 'eme-select2-locale', $locale_file_url, [ 'eme-select2' ], EME_VERSION, $load_js_in_footer ); } } - wp_register_script( 'eme-basic', $eme_plugin_url . 'js/eme.js', array( 'jquery' ), EME_VERSION, $load_js_in_footer ); - $translation_array = array( + wp_register_script( 'eme-basic', $eme_plugin_url . 'js/eme.js', [ 'jquery' ], EME_VERSION, $load_js_in_footer ); + $translation_array = [ 'translate_plugin_url' => $eme_plugin_url, 'translate_ajax_url' => admin_url( 'admin-ajax.php' ), 'translate_selectstate' => __( 'State', 'events-made-easy' ), @@ -560,15 +560,15 @@ function eme_register_scripts() { 'translate_flanguage' => $language, 'translate_fdateformat' => $eme_wp_date_format, 'translate_ftimeformat' => $eme_wp_time_format, - ); + ]; wp_localize_script( 'eme-basic', 'emebasic', $translation_array ); if ( get_option( 'eme_use_client_clock' ) && ! isset( $_COOKIE['eme_client_time'] ) ) { // client clock should be executed asap, so load it in the header, and no defer - $translation_array = array( + $translation_array = [ 'translate_ajax_url' => admin_url( 'admin-ajax.php' ), - ); - wp_register_script( 'eme-client_clock_submit', $eme_plugin_url . 'js/client-clock.js', array( 'jquery' ), EME_VERSION ); + ]; + wp_register_script( 'eme-client_clock_submit', $eme_plugin_url . 'js/client-clock.js', [ 'jquery' ], EME_VERSION ); wp_localize_script( 'eme-client_clock_submit', 'emeclock', $translation_array ); wp_enqueue_script( 'eme-client_clock_submit' ); } @@ -576,25 +576,25 @@ function eme_register_scripts() { // the frontend also needs the autocomplete (rsvp form) $search_tables = get_option( 'eme_autocomplete_sources' ); if ( $search_tables != 'none' && is_user_logged_in() ) { - wp_register_script( 'eme-autocomplete-form', $eme_plugin_url . 'js/eme_autocomplete_form.js', array( 'jquery-ui-autocomplete' ), EME_VERSION, $load_js_in_footer ); + wp_register_script( 'eme-autocomplete-form', $eme_plugin_url . 'js/eme_autocomplete_form.js', [ 'jquery-ui-autocomplete' ], EME_VERSION, $load_js_in_footer ); } - wp_register_script( 'eme-leaflet-maps', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.js', array( 'jquery' ), EME_VERSION, true ); - wp_register_script( 'eme-leaflet-gestures', $eme_plugin_url . 'js/leaflet-gesturehandling-1.2.1/leaflet-gesture-handling.min.js', array( 'jquery', 'eme-leaflet-maps' ), EME_VERSION, true ); - wp_register_script( 'eme-leaflet-markercluster', $eme_plugin_url . 'js/leaflet-markercluster-1.4.1/leaflet.markercluster.js', array( 'eme-leaflet-maps' ), EME_VERSION, true ); + wp_register_script( 'eme-leaflet-maps', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.js', [ 'jquery' ], EME_VERSION, true ); + wp_register_script( 'eme-leaflet-gestures', $eme_plugin_url . 'js/leaflet-gesturehandling-1.2.1/leaflet-gesture-handling.min.js', [ 'jquery', 'eme-leaflet-maps' ], EME_VERSION, true ); + wp_register_script( 'eme-leaflet-markercluster', $eme_plugin_url . 'js/leaflet-markercluster-1.4.1/leaflet.markercluster.js', [ 'eme-leaflet-maps' ], EME_VERSION, true ); wp_register_style( 'eme-leaflet-css', $eme_plugin_url . 'js/leaflet-1.8.0/leaflet.css', EME_VERSION, false ); wp_register_style( 'eme-markercluster-css1', $eme_plugin_url . 'js/leaflet-markercluster-1.4.1/MarkerCluster.css', EME_VERSION, false ); wp_register_style( 'eme-markercluster-css2', $eme_plugin_url . 'js/leaflet-markercluster-1.4.1/MarkerCluster.Default.css', EME_VERSION, false ); wp_register_style( 'eme-gestures-css', $eme_plugin_url . 'js/leaflet-gesturehandling-1.2.1/leaflet-gesture-handling.min.css', EME_VERSION, false ); - wp_register_script( 'eme-location-map', $eme_plugin_url . 'js/eme_location_map.js', array( 'jquery', 'eme-leaflet-maps' ), EME_VERSION, true ); + wp_register_script( 'eme-location-map', $eme_plugin_url . 'js/eme_location_map.js', [ 'jquery', 'eme-leaflet-maps' ], EME_VERSION, true ); if ( get_option( 'eme_recaptcha_for_forms' ) ) { // using explicit rendering of the captcha would allow to capture the widget id and reset it if needed, but we won't use that ... //wp_register_script( 'eme-recaptcha', 'https://www.google.com/recaptcha/api.js?onload=eme_CaptchaCallback&render=explicit', array('eme-basic'), '',true); - wp_register_script( 'eme-recaptcha', 'https://www.google.com/recaptcha/api.js', array( 'eme-basic' ), '', true ); + wp_register_script( 'eme-recaptcha', 'https://www.google.com/recaptcha/api.js', [ 'eme-basic' ], '', true ); } if ( get_option( 'eme_hcaptcha_for_forms' ) ) { - wp_register_script( 'eme-hcaptcha', 'https://js.hcaptcha.com/1/api.js', array( 'eme-basic' ), '', true ); + wp_register_script( 'eme-hcaptcha', 'https://js.hcaptcha.com/1/api.js', [ 'eme-basic' ], '', true ); } } add_action( 'wp_enqueue_scripts', 'eme_register_scripts' ); @@ -615,15 +615,15 @@ function eme_enqueue_frontend() { if ( get_option( 'eme_massmail_popup' ) ) { wp_enqueue_script( 'jquery-ui-dialog' ); } - wp_enqueue_style( 'eme-jquery-ui-css', $eme_plugin_url . 'css/jquery-ui-theme-smoothness-1.11.3/jquery-ui.min.css', array(), EME_VERSION ); - wp_enqueue_style( 'eme-jquery-ui-autocomplete', $eme_plugin_url . 'css/jquery.autocomplete.css', array(), EME_VERSION ); - wp_enqueue_style( 'eme-jquery-select2-css', $eme_plugin_url . 'js/jquery-select2/select2-4.1.0-rc.0/dist/css/select2.min.css', array(), EME_VERSION ); + wp_enqueue_style( 'eme-jquery-ui-css', $eme_plugin_url . 'css/jquery-ui-theme-smoothness-1.11.3/jquery-ui.min.css', [], EME_VERSION ); + wp_enqueue_style( 'eme-jquery-ui-autocomplete', $eme_plugin_url . 'css/jquery.autocomplete.css', [], EME_VERSION ); + wp_enqueue_style( 'eme-jquery-select2-css', $eme_plugin_url . 'js/jquery-select2/select2-4.1.0-rc.0/dist/css/select2.min.css', [], EME_VERSION ); - wp_enqueue_style( 'eme_textsec', $eme_plugin_url . 'css/text-security/text-security-disc.css', array(), EME_VERSION ); - wp_enqueue_style( 'eme_stylesheet', $eme_plugin_url . 'css/eme.css', array(), EME_VERSION ); + wp_enqueue_style( 'eme_textsec', $eme_plugin_url . 'css/text-security/text-security-disc.css', [], EME_VERSION ); + wp_enqueue_style( 'eme_stylesheet', $eme_plugin_url . 'css/eme.css', [], EME_VERSION ); $eme_css_name = get_stylesheet_directory() . '/eme.css'; if ( file_exists( $eme_css_name ) ) { - wp_enqueue_style( 'eme_stylesheet_extra', get_stylesheet_directory_uri() . '/eme.css', 'eme_stylesheet', array(), EME_VERSION ); + wp_enqueue_style( 'eme_stylesheet_extra', get_stylesheet_directory_uri() . '/eme.css', 'eme_stylesheet', [], EME_VERSION ); } } } @@ -657,7 +657,7 @@ function eme_admin_notices() { } // only show the notices to admin users - $allowed_roles = array( 'administrator' ); + $allowed_roles = [ 'administrator' ]; if ( array_intersect( $allowed_roles, $current_user->roles ) ) { $single = true; $eme_hello_notice_ignore = get_user_meta( $user_id, 'eme_hello_notice_ignore', $single ); @@ -668,7 +668,7 @@ function eme_admin_notices() { $eme_donate_notice_ignore = 0; } if ( ! $eme_hello_notice_ignore && preg_match( '/^eme-/', $plugin_page ) ) { ?> -
Hey, %1\$s, welcome to Events Made Easy! We hope you like it around here.

Now it's time to insert events lists through widgets, template tags or shortcodes.

By the way, have you taken a look at the Settings page? That's where you customize the way events and locations are displayed.

What? Tired of seeing this advice? I hear you, click here and you won't see this again!

", 'events-made-easy' ), $current_user->display_name, admin_url( 'widgets.php' ), '//www.e-dynamics.be/wordpress/#template-tags', '//www.e-dynamics.be/wordpress/#shortcodes', admin_url( 'admin.php?page=eme-options' ), add_query_arg( array( 'eme_notice_ignore' => 'hello' ), remove_query_arg( 'eme_notice_ignore' ) ) ); ?>
+
Hey, %1\$s, welcome to Events Made Easy! We hope you like it around here.

Now it's time to insert events lists through widgets, template tags or shortcodes.

By the way, have you taken a look at the Settings page? That's where you customize the way events and locations are displayed.

What? Tired of seeing this advice? I hear you, click here and you won't see this again!

", 'events-made-easy' ), $current_user->display_name, admin_url( 'widgets.php' ), '//www.e-dynamics.be/wordpress/#template-tags', '//www.e-dynamics.be/wordpress/#shortcodes', admin_url( 'admin.php?page=eme-options' ), add_query_arg( [ 'eme_notice_ignore' => 'hello' ], remove_query_arg( 'eme_notice_ignore' ) ) ); ?>
Donate using Liberapay

I already donated.', 'events-made-easy' ), add_query_arg( array( 'eme_notice_ignore' => 'donate' ), remove_query_arg( 'eme_notice_ignore' ) ) ); + echo sprintf( __( 'I already donated.', 'events-made-easy' ), add_query_arg( [ 'eme_notice_ignore' => 'donate' ], remove_query_arg( 'eme_notice_ignore' ) ) ); ?> @@ -755,7 +755,7 @@ function eme_del_upload_ajax() { } $fname = "$random_id-$field_id-$extra_id-$clean.$clean_ext"; - if ( in_array( $type, array( 'bookings', 'people', 'members' ) ) ) { + if ( in_array( $type, [ 'bookings', 'people', 'members' ] ) ) { eme_delete_uploaded_file( $fname, $id, $type ); } } @@ -782,10 +782,10 @@ function eme_enqueue_datetimepicker() { } $eme_plugin_dir = eme_plugin_dir(); - wp_enqueue_script( 'eme-jquery-timepicker', $eme_plugin_url . 'js/jquery-timepicker/jquery.timepicker.min.js', array( 'jquery' ), EME_VERSION, $load_js_in_footer ); - wp_enqueue_style( 'eme-jquery-timepicker', $eme_plugin_url . 'js/jquery-timepicker/jquery.timepicker.min.css', array(), EME_VERSION ); - wp_enqueue_script( 'eme-jquery-fdatepicker', $eme_plugin_url . 'js/fdatepicker/js/fdatepicker.min.js', array( 'jquery' ), EME_VERSION, $load_js_in_footer ); - wp_enqueue_style( 'eme-jquery-fdatepicker', $eme_plugin_url . 'js/fdatepicker/css/fdatepicker.min.css', array(), EME_VERSION ); + wp_enqueue_script( 'eme-jquery-timepicker', $eme_plugin_url . 'js/jquery-timepicker/jquery.timepicker.min.js', [ 'jquery' ], EME_VERSION, $load_js_in_footer ); + wp_enqueue_style( 'eme-jquery-timepicker', $eme_plugin_url . 'js/jquery-timepicker/jquery.timepicker.min.css', [], EME_VERSION ); + wp_enqueue_script( 'eme-jquery-fdatepicker', $eme_plugin_url . 'js/fdatepicker/js/fdatepicker.min.js', [ 'jquery' ], EME_VERSION, $load_js_in_footer ); + wp_enqueue_style( 'eme-jquery-fdatepicker', $eme_plugin_url . 'js/fdatepicker/css/fdatepicker.min.css', [], EME_VERSION ); // fdatepicker only needs the language (for now) $language = eme_detect_lang(); // for english, no translation code is needed) @@ -793,7 +793,7 @@ function eme_enqueue_datetimepicker() { $locale_file = $eme_plugin_dir . "js/fdatepicker/js/i18n/fdatepicker.$language.js"; $locale_file_url = $eme_plugin_url . "js/fdatepicker/js/i18n/fdatepicker.$language.js"; if ( file_exists( $locale_file ) ) { - wp_enqueue_script( 'eme-jquery-fdatepick-locale', $locale_file_url, array( 'eme-jquery-fdatepicker' ), EME_VERSION, $load_js_in_footer ); + wp_enqueue_script( 'eme-jquery-fdatepick-locale', $locale_file_url, [ 'eme-jquery-fdatepicker' ], EME_VERSION, $load_js_in_footer ); } } } diff --git a/eme-attendances.php b/eme-attendances.php index 0596dcf3..d08f91fb 100644 --- a/eme-attendances.php +++ b/eme-attendances.php @@ -8,7 +8,7 @@ function eme_db_insert_attendance( $type, $person_id, $attendance_date = '', $re global $wpdb,$eme_db_prefix; $table_name = $eme_db_prefix . ATTENDANCES_TBNAME; - $line = array(); + $line = []; $line['type'] = esc_sql( $type ); $line['person_id'] = intval( $person_id ); if ( ! empty( $attendance_date ) && ( eme_is_date( $attendance_date ) || eme_is_datetime( $attendance_date ) ) ) { @@ -37,14 +37,14 @@ function eme_delete_old_attendances() { } $old_date = $eme_date_obj->minusDays( $remove_old_attendances_days )->getDateTime(); - $wpdb->query( $wpdb->prepare("DELETE FROM $table_name WHERE creation_date<%s",$old_date) ); + $wpdb->query( $wpdb->prepare("DELETE FROM $table_name WHERE creation_date<%s", $old_date) ); } function eme_delete_attendances( $ids ) { global $wpdb,$eme_db_prefix; $attendances_table = $eme_db_prefix . ATTENDANCES_TBNAME; if (eme_is_list_of_int($ids) ) { - $ids_arr = explode(',',$ids); + $ids_arr = explode(',', $ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); $sql = $wpdb->prepare( "DELETE FROM $attendances_table WHERE id IN ( $commaDelimitedPlaceholders )", $ids_arr); $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared @@ -55,7 +55,7 @@ function eme_delete_person_attendances( $ids ) { global $wpdb,$eme_db_prefix; $attendances_table = $eme_db_prefix . ATTENDANCES_TBNAME; if (eme_is_list_of_int($ids) ) { - $ids_arr = explode(',',$ids); + $ids_arr = explode(',', $ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); $sql = $wpdb->prepare( "DELETE FROM $attendances_table WHERE person_id IN ( $commaDelimitedPlaceholders )", $ids_arr); $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared @@ -65,14 +65,14 @@ function eme_delete_person_attendances( $ids ) { function eme_delete_event_attendances( $event_id ) { global $wpdb,$eme_db_prefix; $attendances_table = $eme_db_prefix . ATTENDANCES_TBNAME; - $sql = $wpdb->prepare( "DELETE FROM $attendances_table WHERE type='event' AND related_id=%d",$event_id); + $sql = $wpdb->prepare( "DELETE FROM $attendances_table WHERE type='event' AND related_id=%d", $event_id); $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared } function eme_delete_membership_attendances( $membership_id ) { global $wpdb,$eme_db_prefix; $attendances_table = $eme_db_prefix . ATTENDANCES_TBNAME; - $sql = $wpdb->prepare( "DELETE FROM $attendances_table WHERE type='membership' AND related_id=%d",$membership_id); + $sql = $wpdb->prepare( "DELETE FROM $attendances_table WHERE type='membership' AND related_id=%d", $membership_id); $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared } @@ -81,7 +81,7 @@ function eme_attendances_page() { } function eme_attendance_types() { - $att_names = array(); + $att_names = []; $att_types['any'] = __( 'Any', 'events-made-easy' ); $att_types['event'] = __( 'Events', 'events-made-easy' ); $att_types['membership'] = __( 'Memberships', 'events-made-easy' ); @@ -162,7 +162,7 @@ function eme_ajax_attendances_list() { global $wpdb,$eme_db_prefix, $eme_timezone; check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); $table = $eme_db_prefix . ATTENDANCES_TBNAME; - $jTableResult = array(); + $jTableResult = []; $search_type = isset( $_REQUEST['search_type'] ) ? esc_sql( eme_sanitize_request( $_REQUEST['search_type'] ) ) : ''; $search_start_date = isset( $_REQUEST['search_start_date'] ) && eme_is_date( $_REQUEST['search_start_date'] ) ? esc_sql( $_REQUEST['search_start_date'] ) : ''; $search_end_date = isset( $_REQUEST['search_end_date'] ) && eme_is_date( $_REQUEST['search_end_date'] ) ? esc_sql( $_REQUEST['search_end_date'] ) : ''; @@ -170,7 +170,7 @@ function eme_ajax_attendances_list() { $att_types = eme_attendance_types(); $where = ''; - $where_arr = array(); + $where_arr = []; if ( ! empty( $search_start_date ) && ! empty( $search_end_date ) ) { $where_arr[] = "creation_date >= '$search_start_date'"; $where_arr[] = "creation_date <= '$search_end_date'"; @@ -257,7 +257,7 @@ function eme_ajax_manage_attendances() { if ( ! current_user_can( get_option( 'eme_cap_list_attendances' ) ) ) { wp_die(); } - $ajaxResult = array(); + $ajaxResult = []; if ( isset( $_REQUEST['do_action'] ) ) { $do_action = eme_sanitize_request( $_REQUEST['do_action'] ); switch ( $do_action ) { @@ -271,7 +271,7 @@ function eme_ajax_manage_attendances() { function eme_ajax_action_attendances_delete( $ids ) { eme_delete_events( $ids ); - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'OK'; $ajaxResult['Message'] = __( 'Events deleted', 'events-made-easy' ); print wp_json_encode( $ajaxResult ); diff --git a/eme-attributes.php b/eme-attributes.php index 00289bbc..708338c4 100644 --- a/eme-attributes.php +++ b/eme-attributes.php @@ -5,7 +5,7 @@ } function eme_attributes_form( $eme_array ) { - $eme_data = array(); + $eme_data = []; if ( isset( $eme_array['event_attributes'] ) ) { $eme_data = $eme_array['event_attributes']; } elseif ( isset( $eme_array['location_attributes'] ) ) { @@ -75,7 +75,7 @@ function eme_attributes_form( $eme_array ) { //We now have one long string of formats preg_match_all( '/#(ESC|URL)?_ATT\{.+?\}(\{.+?\})?/', $formats, $placeholders ); - $attributes = array(); + $attributes = []; //Now grab all the unique attributes we can use in our event or location. foreach ( $placeholders[0] as $result ) { $result = str_replace( '#ESC', '#', $result ); diff --git a/eme-calendar.php b/eme-calendar.php index dd033089..5ffe07ff 100644 --- a/eme-calendar.php +++ b/eme-calendar.php @@ -8,8 +8,8 @@ function eme_get_calendar_shortcode( $atts ) { global $eme_timezone; eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'category' => 0, 'notcategory' => 0, 'full' => 0, @@ -26,8 +26,8 @@ function eme_get_calendar_shortcode( $atts ) { 'htmltable' => 1, 'htmldiv' => 0, 'weekdays' => '', - ), - $atts + ], + $atts ) ); @@ -56,7 +56,7 @@ function eme_get_calendar_shortcode( $atts ) { $month = 1; } - $location_id_arr = array(); + $location_id_arr = []; // the filter list overrides the settings if ( ! $ignore_filter && isset( $_REQUEST['eme_eventAction'] ) && eme_sanitize_request( $_REQUEST['eme_eventAction']) == 'filter' ) { if ( ! empty( $_REQUEST['eme_scope_filter'] ) ) { @@ -128,7 +128,7 @@ function eme_get_calendar_shortcode( $atts ) { function eme_get_calendar( $args = '' ) { global $wp_locale, $eme_timezone; - $defaults = array( + $defaults = [ 'category' => 0, 'notcategory' => 0, 'full' => 0, @@ -144,7 +144,7 @@ function eme_get_calendar( $args = '' ) { 'htmltable' => 1, 'htmldiv' => 0, 'weekdays' => '', - ); + ]; $r = wp_parse_args( $args, $defaults ); extract( $r ); $echo = filter_var( $echo, FILTER_VALIDATE_BOOLEAN ); @@ -154,7 +154,7 @@ function eme_get_calendar( $args = '' ) { if ( ! empty( $weekdays ) ) { $weekday_arr = explode( ',', $weekdays ); } else { - $weekday_arr = array(); + $weekday_arr = []; } // this comes from global WordPress preferences @@ -173,10 +173,10 @@ function eme_get_calendar( $args = '' ) { try { $client_timeinfo = eme_sanitize_request( json_decode( $_COOKIE['eme_client_time'], true ) ); if ( ! is_array( $client_timeinfo ) ) { - $client_timeinfo = array(); + $client_timeinfo = []; } } catch ( Exception $error ) { - $client_timeinfo = array(); + $client_timeinfo = []; } // avoid php warnings if ( ! isset( $client_timeinfo['eme_client_unixtime'] ) ) { @@ -203,11 +203,11 @@ function eme_get_calendar( $args = '' ) { $iNowYear = 0; } if ( empty( $iNowDay ) || empty( $iNowMonth ) || empty( $iNowYear ) ) { - list($iNowYear, $iNowMonth, $iNowDay) = explode( '-', $eme_date_obj->getDate() ); + [$iNowYear, $iNowMonth, $iNowDay] = explode( '-', $eme_date_obj->getDate() ); } } else { // Get current year, month and day - list($iNowYear, $iNowMonth, $iNowDay) = explode( '-', $eme_date_obj->getDate() ); + [$iNowYear, $iNowMonth, $iNowDay] = explode( '-', $eme_date_obj->getDate() ); } $iSelectedYear = $year; @@ -317,7 +317,7 @@ function eme_get_calendar( $args = '' ) { $calend = "$iNextYear-$iNextMonth-07"; $events = eme_get_events( 0, "$calbegin--$calend", 'ASC', 0, $location_id, $category, $author, $contact_person, 1, $notcategory ); - $eventful_days = array(); + $eventful_days = []; if ( $events ) { // go through the events and slot them into the right d-m index foreach ( $events as $event ) { @@ -346,7 +346,7 @@ function eme_get_calendar( $args = '' ) { if ( isset( $eventful_days[ $event_eventful_date ] ) && is_array( $eventful_days[ $event_eventful_date ] ) ) { $eventful_days[ $event_eventful_date ][] = $event; } else { - $eventful_days[ $event_eventful_date ] = array( $event ); + $eventful_days[ $event_eventful_date ] = [ $event ]; } $eme_date_obj_tmp->addOneDay(); } @@ -356,7 +356,7 @@ function eme_get_calendar( $args = '' ) { if ( isset( $eventful_days[ $event_start_date ] ) && is_array( $eventful_days[ $event_start_date ] ) ) { $eventful_days[ $event_start_date ][] = $event; } else { - $eventful_days[ $event_start_date ] = array( $event ); + $eventful_days[ $event_start_date ] = [ $event ]; } } } @@ -371,9 +371,9 @@ function eme_get_calendar( $args = '' ) { $event_title_format = get_option( 'eme_small_calendar_event_title_format' ); $event_title_separator_format = get_option( 'eme_small_calendar_event_title_separator' ); - $cells = array(); - $holidays = array(); - $holiday_titles = array(); + $cells = []; + $holidays = []; + $holiday_titles = []; if ( $holiday_id ) { $holidays = eme_get_holiday_listinfo( $holiday_id ); if ( $holidays ) { @@ -416,7 +416,7 @@ function eme_get_calendar( $args = '' ) { foreach ( $eventful_days as $day_key => $events ) { // Set the date into the key - $events_titles = array(); + $events_titles = []; if ( isset( $holiday_titles[ $day_key ] ) ) { $events_titles[] = $holiday_titles[ $day_key ]; } @@ -431,23 +431,23 @@ function eme_get_calendar( $args = '' ) { // Let's add the possible options // template_id is not being used per event if ( ! empty( $location_id ) ) { - $cal_day_link = add_query_arg( array( 'location_id' => $location_id ), $cal_day_link ); + $cal_day_link = add_query_arg( [ 'location_id' => $location_id ], $cal_day_link ); } if ( ! empty( $category ) ) { - $cal_day_link = add_query_arg( array( 'category' => $category ), $cal_day_link ); + $cal_day_link = add_query_arg( [ 'category' => $category ], $cal_day_link ); } if ( ! empty( $notcategory ) ) { - $cal_day_link = add_query_arg( array( 'notcategory' => $notcategory ), $cal_day_link ); + $cal_day_link = add_query_arg( [ 'notcategory' => $notcategory ], $cal_day_link ); } // the hash char and everything following it in a GET is not getting through a browser request, so we replace "#_MYSELF" with just "_MYSELF" here $author = str_replace( '#_MYSELF', '_MYSELF', $author ); $contact_person = str_replace( '#_MYSELF', '_MYSELF', $contact_person ); if ( ! empty( $author ) ) { - $cal_day_link = add_query_arg( array( 'author' => $author ), $cal_day_link ); + $cal_day_link = add_query_arg( [ 'author' => $author ], $cal_day_link ); } if ( ! empty( $contact_person ) ) { - $cal_day_link = add_query_arg( array( 'contact_person' => $contact_person ), $cal_day_link ); + $cal_day_link = add_query_arg( [ 'contact_person' => $contact_person ], $cal_day_link ); } $event_date = explode( '-', $day_key ); @@ -570,8 +570,8 @@ function eme_get_calendar( $args = '' ) { $sCalDivRows .= "\n"; } - $weekday_names = array( __( 'Sunday' ), __( 'Monday' ), __( 'Tuesday' ), __( 'Wednesday' ), __( 'Thursday' ), __( 'Friday' ), __( 'Saturday' ) ); - $weekday_header_class = array( 'Sun_header', 'Mon_header', 'Tue_header', 'Wed_header', 'Thu_header', 'Fri_header', 'Sat_header' ); + $weekday_names = [ __( 'Sunday' ), __( 'Monday' ), __( 'Tuesday' ), __( 'Wednesday' ), __( 'Thursday' ), __( 'Friday' ), __( 'Saturday' ) ]; + $weekday_header_class = [ 'Sun_header', 'Mon_header', 'Tue_header', 'Wed_header', 'Thu_header', 'Fri_header', 'Sat_header' ]; $sCalTblDayNames = ''; $sCalDivDayNames = ''; // respect the beginning of the week offset diff --git a/eme-categories.php b/eme-categories.php index 05ca33ba..d2a6e797 100644 --- a/eme-categories.php +++ b/eme-categories.php @@ -5,12 +5,12 @@ } function eme_new_category() { - $category = array( + $category = [ 'category_name' => '', 'category_slug' => '', 'category_prefix' => '', 'description' => '', - ); + ]; return $category; } @@ -44,7 +44,7 @@ function eme_categories_page() { check_admin_referer( 'eme_admin', 'eme_admin_nonce' ); if ( $_POST['eme_admin_action'] == 'do_editcategory' ) { // category update required - $category = array(); + $category = []; $category['category_name'] = eme_sanitize_request( $_POST['category_name'] ); $category['description'] = eme_kses( $_POST['description'] ); if ( ! empty( $_POST['category_prefix'] ) ) { @@ -56,7 +56,7 @@ function eme_categories_page() { $category['category_slug'] = eme_permalink_convert_noslash( $category['category_name'] ); } if ( isset( $_POST['category_id'] ) && intval( $_POST['category_id'] ) > 0 ) { - $validation_result = $wpdb->update( $categories_table, $category, array( 'category_id' => intval( $_POST['category_id'] ) ) ); + $validation_result = $wpdb->update( $categories_table, $category, [ 'category_id' => intval( $_POST['category_id'] ) ] ); if ( $validation_result !== false ) { $message = __( 'Successfully edited the category', 'events-made-easy' ); } else { @@ -247,7 +247,7 @@ function eme_categories_edit_layout( $message = '' ) { } if ( preg_match( '/,/', $categories_prefixes ) ) { $categories_prefixes = explode( ',', $categories_prefixes ); - $categories_prefixes_arr = array(); + $categories_prefixes_arr = []; foreach ( $categories_prefixes as $categories_prefix ) { $categories_prefixes_arr[ $categories_prefix ] = eme_permalink_convert( $categories_prefix ); } @@ -286,7 +286,7 @@ function eme_get_cached_categories() { function eme_get_categories( $eventful = false, $scope = 'future', $extra_conditions = '' ) { global $wpdb,$eme_db_prefix; $categories_table = $eme_db_prefix . CATEGORIES_TBNAME; - $categories = array(); + $categories = []; $order_by = ' ORDER BY category_name ASC'; if ( $eventful ) { $events = eme_get_events( 0, $scope, 'ASC' ); @@ -325,7 +325,7 @@ function eme_get_categories( $eventful = false, $scope = 'future', $extra_condit function eme_get_categories_filtered( $category_ids, $categories ) { $cat_id_arr = explode( ',', $category_ids ); - $new_arr = array(); + $new_arr = []; foreach ( $categories as $cat ) { if ( in_array( $cat['category_id'], $cat_id_arr ) ) { $new_arr[] = $cat; @@ -395,7 +395,7 @@ function eme_get_category_eventids( $category_id, $future_only = 1 ) { $extra_condition = "AND event_start > '$today'"; } $cat_ids = explode( ',', $category_id ); - $event_ids = array(); + $event_ids = []; foreach ( $cat_ids as $cat_id ) { $sql = $wpdb->prepare( "SELECT event_id FROM $events_table WHERE FIND_IN_SET(%d,event_category_ids) $extra_condition ORDER BY event_start ASC, event_name ASC", $cat_id ); if ( empty( $event_ids ) ) { @@ -452,7 +452,7 @@ function eme_get_location_category_descriptions( $location_id, $extra_conditions function eme_get_category_ids( $cat_slug ) { global $wpdb,$eme_db_prefix; $categories_table = $eme_db_prefix . CATEGORIES_TBNAME; - $cat_ids = array(); + $cat_ids = []; if ( ! empty( $cat_slug ) ) { $sql = $wpdb->prepare( "SELECT DISTINCT category_id FROM $categories_table WHERE category_slug = %s", $cat_slug ); $cat_ids = $wpdb->get_col( $sql ); @@ -463,16 +463,16 @@ function eme_get_category_ids( $cat_slug ) { function eme_get_categories_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'event_id' => 0, 'eventful' => false, 'scope' => 'all', 'template_id' => 0, 'template_id_header' => 0, 'template_id_footer' => 0, - ), - $atts + ], + $atts ) ); $eventful = filter_var( $eventful, FILTER_VALIDATE_BOOLEAN ); diff --git a/eme-cleanup.php b/eme-cleanup.php index be63a2e5..43a85827 100644 --- a/eme-cleanup.php +++ b/eme-cleanup.php @@ -156,9 +156,9 @@ function eme_cleanup_events( $eme_number, $eme_period ) { function eme_cleanup_all_event_related_data( $other_data ) { global $wpdb,$eme_db_prefix; - $tables = array( EVENTS_TBNAME, EVENTS_CF_TBNAME, BOOKINGS_TBNAME, LOCATIONS_TBNAME, LOCATIONS_CF_TBNAME, RECURRENCE_TBNAME, ANSWERS_TBNAME, PAYMENTS_TBNAME, PEOPLE_TBNAME, MEMBERS_TBNAME, MEMBERSHIPS_CF_TBNAME, MEMBERSHIPS_TBNAME, ATTENDANCES_TBNAME ); + $tables = [ EVENTS_TBNAME, EVENTS_CF_TBNAME, BOOKINGS_TBNAME, LOCATIONS_TBNAME, LOCATIONS_CF_TBNAME, RECURRENCE_TBNAME, ANSWERS_TBNAME, PAYMENTS_TBNAME, PEOPLE_TBNAME, MEMBERS_TBNAME, MEMBERSHIPS_CF_TBNAME, MEMBERSHIPS_TBNAME, ATTENDANCES_TBNAME ]; if ( $other_data ) { - $tables2 = array( CATEGORIES_TBNAME, HOLIDAYS_TBNAME, TEMPLATES_TBNAME, FORMFIELDS_TBNAME, COUNTRIES_TBNAME, STATES_TBNAME ); + $tables2 = [ CATEGORIES_TBNAME, HOLIDAYS_TBNAME, TEMPLATES_TBNAME, FORMFIELDS_TBNAME, COUNTRIES_TBNAME, STATES_TBNAME ]; $tables = array_merge( $tables, $tables2 ); } foreach ( $tables as $table ) { @@ -175,7 +175,7 @@ function eme_cleanup_page() { if ( $_POST['eme_admin_action'] == 'eme_cleanup_events' && isset( $_POST['eme_number'] ) && isset( $_POST['eme_period'] ) ) { $eme_number = intval( $_POST['eme_number'] ); $eme_period = eme_sanitize_request( $_POST['eme_period'] ); - if ( ! in_array( $eme_period, array( 'day', 'week', 'month' ) ) ) { + if ( ! in_array( $eme_period, [ 'day', 'week', 'month' ] ) ) { $eme_period = 'month'; } diff --git a/eme-countries.php b/eme-countries.php index 07b1b947..0be9e1c3 100644 --- a/eme-countries.php +++ b/eme-countries.php @@ -5,22 +5,22 @@ } function eme_new_country() { - $country = array( + $country = [ 'alpha_2' => '', 'alpha_3' => '', 'num_3' => '', 'name' => '', 'lang' => '', - ); + ]; return $country; } function eme_new_state() { - $state = array( + $state = [ 'code' => '', 'name' => '', 'country_id' => 0, - ); + ]; return $state; } @@ -33,7 +33,7 @@ function eme_countries_page() { } $message = ''; - $csvMimes = array( 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ); + $csvMimes = [ 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ]; // handle possible ations if ( isset( $_POST['eme_admin_action'] ) ) { @@ -729,7 +729,7 @@ function eme_db_update_country( $id, $line ) { // we only want the columns that interest us $keys = array_intersect_key( $line, $country ); $new_line = array_merge( $country, $keys ); - $where = array( 'id' => $id ); + $where = [ 'id' => $id ]; if ( isset( $new_line['id'] ) ) { unset( $new_line['id'] ); } @@ -775,7 +775,7 @@ function eme_db_update_state( $id, $line ) { // we only want the columns that interest us $keys = array_intersect_key( $line, $state ); $new_line = array_merge( $state, $keys ); - $where = array( 'id' => $id ); + $where = [ 'id' => $id ]; if ( isset( $new_line['id'] ) ) { unset( $new_line['id'] ); } @@ -844,7 +844,7 @@ function eme_get_state_name( $code, $country_code, $lang = '' ) { function eme_get_countries_lang() { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . COUNTRIES_TBNAME; - $jTableResult = array(); + $jTableResult = []; $sql = "SELECT id, CONCAT (name, ' (', lang, ')') AS name FROM $table"; return $wpdb->get_results( $sql, ARRAY_A ); } @@ -858,12 +858,12 @@ function eme_ajax_countries_list() { global $wpdb,$eme_db_prefix; check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); $table = $eme_db_prefix . COUNTRIES_TBNAME; - $jTableResult = array(); + $jTableResult = []; // The toolbar search input $q = isset( $_REQUEST['q'] ) ? eme_sanitize_request($_REQUEST['q']) : ''; $opt = isset( $_REQUEST['opt'] ) ? eme_sanitize_request($_REQUEST['opt']) : ''; $where = ''; - $where_array = array(); + $where_array = []; if ( $q ) { for ( $i = 0; $i < count( $opt ); $i++ ) { $fld = esc_sql( $opt[ $i ] ); @@ -902,7 +902,7 @@ function eme_ajax_states_list() { check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); $table = $eme_db_prefix . STATES_TBNAME; $countries_table = $eme_db_prefix . COUNTRIES_TBNAME; - $jTableResult = array(); + $jTableResult = []; if ( current_user_can( get_option( 'eme_cap_settings' ) ) ) { $sql = "SELECT COUNT(*) FROM $table"; $recordCount = $wpdb->get_var( $sql ); @@ -981,7 +981,7 @@ function eme_ajax_country_delete() { function eme_ajax_state_edit() { check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); - $jTableResult = array(); + $jTableResult = []; if ( isset( $_POST['id'] ) ) { $state = eme_get_state( intval( $_POST['id'] ) ); @@ -1056,13 +1056,13 @@ function eme_select_state_ajax() { $q = isset( $_REQUEST['q'] ) ? eme_sanitize_request( $_REQUEST['q'] ) : ''; $country_code = isset( $_POST['country_code'] ) ? eme_sanitize_request( $_POST['country_code'] ) : ''; // the country code can be empty, in which case eme_get_localized_states will return states if only 1 country exists - $records = array(); + $records = []; $states = eme_get_localized_states( $country_code ); foreach ( $states as $state ) { if ( ! empty( $q ) && ! stristr( $state['name'], $q ) ) { continue; } - $record = array(); + $record = []; $record['id'] = $state['code']; $record['text'] = $state['name']; $records[] = $record; @@ -1079,13 +1079,13 @@ function eme_select_state_ajax() { function eme_select_country_ajax() { check_ajax_referer( 'eme_frontend', 'eme_frontend_nonce' ); $q = isset( $_REQUEST['q'] ) ? eme_sanitize_request( $_REQUEST['q'] ) : ''; - $records = array(); + $records = []; $countries = eme_get_localized_countries(); foreach ( $countries as $country ) { if ( ! empty( $q ) && ! stristr( $country['name'], $q ) ) { continue; } - $record = array(); + $record = []; $record['id'] = $country['alpha_2']; $record['text'] = $country['name']; $records[] = $record; diff --git a/eme-cron.php b/eme-cron.php index e340c7ed..4954584a 100644 --- a/eme-cron.php +++ b/eme-cron.php @@ -6,34 +6,34 @@ function eme_cron_schedules( $schedules ) { if ( ! isset( $schedules['eme_1min'] ) ) { - $schedules['eme_1min'] = array( + $schedules['eme_1min'] = [ 'interval' => 60, 'display' => __( 'Once every minute (EME schedule)', 'events-made-easy' ), - ); + ]; } if ( ! isset( $schedules['eme_5min'] ) ) { - $schedules['eme_5min'] = array( + $schedules['eme_5min'] = [ 'interval' => 5 * 60, 'display' => __( 'Once every 5 minutes (EME schedule)', 'events-made-easy' ), - ); + ]; } if ( ! isset( $schedules['eme_15min'] ) ) { - $schedules['eme_15min'] = array( + $schedules['eme_15min'] = [ 'interval' => 15 * 60, 'display' => __( 'Once every 15 minutes (EME schedule)', 'events-made-easy' ), - ); + ]; } if ( ! isset( $schedules['eme_30min'] ) ) { - $schedules['eme_30min'] = array( + $schedules['eme_30min'] = [ 'interval' => 30 * 60, 'display' => __( 'Once every 30 minutes (EME schedule)', 'events-made-easy' ), - ); + ]; } if ( ! isset( $schedules['eme_4weeks'] ) ) { - $schedules['eme_4weeks'] = array( + $schedules['eme_4weeks'] = [ 'interval' => 60 * 60 * 24 * 28, 'display' => __( 'Once every 4 weeks (EME schedule)', 'events-made-easy' ), - ); + ]; } return $schedules; } diff --git a/eme-discounts.php b/eme-discounts.php index de955785..8e85535c 100644 --- a/eme-discounts.php +++ b/eme-discounts.php @@ -5,7 +5,7 @@ } function eme_new_discount() { - $discount = array( + $discount = [ 'name' => '', 'description' => '', 'type' => EME_DISCOUNT_TYPE_FIXED, @@ -14,23 +14,23 @@ function eme_new_discount() { 'dgroup' => '', 'valid_from' => '', 'valid_to' => '', - 'properties' => array(), + 'properties' => [], 'use_per_seat' => 0, 'strcase' => 1, 'count' => 0, 'maxcount' => 0, - ); + ]; $discount['properties'] = eme_init_discount_props( $discount['properties'] ); return $discount; } function eme_new_discountgroup() { - $discountgroup = array( + $discountgroup = [ 'name' => '', 'description' => '', 'maxdiscounts' => 0, - ); + ]; return $discountgroup; } @@ -43,10 +43,10 @@ function eme_init_discount_props( $props ) { $props['wp_role'] = ''; } if ( ! isset( $props['group_ids'] ) ) { - $props['group_ids'] = array(); + $props['group_ids'] = []; } if ( ! isset( $props['membership_ids'] ) ) { - $props['membership_ids'] = array(); + $props['membership_ids'] = []; } return $props; } @@ -61,7 +61,7 @@ function eme_discounts_page() { } $message = ''; - $csvMimes = array( 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ); + $csvMimes = [ 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ]; // handle possible ations if ( isset( $_POST['eme_admin_action'] ) ) { @@ -102,7 +102,7 @@ function eme_discounts_page() { if ( ! in_array( 'name', $headers ) || ! in_array( 'type', $headers ) || ! in_array( 'coupon', $headers ) || ! in_array( 'value', $headers ) ) { $message = __( 'Not all required fields present.', 'events-made-easy' ); } else { - $empty_props = array(); + $empty_props = []; $empty_props = eme_init_discount_props( $empty_props ); while ( ( $row = fgetcsv( $handle, 0, $delimiter, $enclosure ) ) !== false ) { $line = array_combine( $headers, $row ); @@ -111,7 +111,7 @@ function eme_discounts_page() { if ( preg_match( '/^prop_(.*)$/', $key, $matches ) ) { $prop = $matches[1]; if ( ! isset( $line['properties'] ) ) { - $line['properties'] = array(); + $line['properties'] = []; } if ( array_key_exists( $prop, $empty_props ) ) { $line['properties'][ $prop ] = $value; @@ -124,7 +124,7 @@ function eme_discounts_page() { $dgroups = $line['group']; $dgroup_arr = explode( ',', $dgroups ); if ( ! eme_array_integers( $dgroup_arr ) ) { - $selected_dgroup_arr = array(); + $selected_dgroup_arr = []; foreach ( $dgroup_arr as $dgroup_name ) { $dgroup = eme_get_discountgroup_by_name( $dgroup_name ); // take the case where the group no longer exists into account @@ -550,7 +550,7 @@ function eme_booking_discount( $event, $booking ) { if ( ! empty( $booking['discountids'] ) ) { $applied_discountids = explode( ',', $booking['discountids'] ); } else { - $applied_discountids = array(); + $applied_discountids = []; } if ( eme_is_admin_request() ) { @@ -558,9 +558,9 @@ function eme_booking_discount( $event, $booking ) { $total_discount = sprintf( '%01.2f', $_POST['DISCOUNT'] ); // if there's an amount entered and it is different than what was calculated before, we clear the discount id references if ( $total_discount != $booking['discount'] ) { - $applied_discountids = array(); + $applied_discountids = []; $discountgroup_id = 0; - $booking['dcodes_used'] = array(); + $booking['dcodes_used'] = []; } } } elseif ( ! empty( $event['event_properties']['rsvp_discountgroup'] ) ) { @@ -578,7 +578,7 @@ function eme_booking_discount( $event, $booking ) { $group_count = 0; $max_discounts = $discount_group['maxdiscounts']; - $booking['dcodes_used'] = array(); + $booking['dcodes_used'] = []; foreach ( $discount_ids as $id ) { // a discount can only be applied once if ( in_array( $id, $applied_discountids ) ) { @@ -621,18 +621,18 @@ function eme_booking_discount( $event, $booking ) { if ( ! empty( $calc_result[1] ) ) { $booking['dcodes_used'] = $calc_result[1]; } else { - $booking['dcodes_used'] = array(); + $booking['dcodes_used'] = []; } } } $discountids = join( ',', array_unique( $applied_discountids ) ); - return array( + return [ 'discount' => $total_discount, 'discountids' => $discountids, 'dgroupid' => $discountgroup_id, 'dcodes_used' => $booking['dcodes_used'], - ); + ]; } function eme_member_discount( $membership, $member ) { @@ -644,7 +644,7 @@ function eme_member_discount( $membership, $member ) { if ( ! empty( $member['discountids'] ) ) { $applied_discountids = explode( ',', $member['discountids'] ); } else { - $applied_discountids = array(); + $applied_discountids = []; } if ( eme_is_admin_request() ) { @@ -652,9 +652,9 @@ function eme_member_discount( $membership, $member ) { $total_discount = sprintf( '%01.2f', $_POST['DISCOUNT'] ); // if there's an amount entered and it is different than what was calculated before, we clear the discount id references if ( $total_discount != $member['discount'] ) { - $applied_discountids = array(); + $applied_discountids = []; $discountgroup_id = 0; - $member['dcodes_used'] = array(); + $member['dcodes_used'] = []; } } } elseif ( ! empty( $membership['properties']['discountgroup'] ) ) { @@ -672,7 +672,7 @@ function eme_member_discount( $membership, $member ) { $group_count = 0; $max_discounts = $discount_group['maxdiscounts']; - $member['dcodes_used'] = array(); + $member['dcodes_used'] = []; foreach ( $discount_ids as $id ) { // a discount can only be applied once if ( in_array( $id, $applied_discountids ) ) { @@ -715,18 +715,18 @@ function eme_member_discount( $membership, $member ) { if ( ! empty( $calc_result[1] ) ) { $member['dcodes_used'] = $calc_result[1]; } else { - $member['dcodes_used'] = array(); + $member['dcodes_used'] = []; } } } $discountids = join( ',', array_unique( $applied_discountids ) ); - return array( + return [ 'discount' => $total_discount, 'discountids' => $discountids, 'dgroupid' => $discountgroup_id, 'dcodes_used' => $member['dcodes_used'], - ); + ]; } function eme_update_booking_discount( $booking ) { @@ -739,8 +739,8 @@ function eme_update_booking_discount( $booking ) { $calc_discount = eme_booking_discount( $event, $booking ); $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking['booking_id']; $fields['discount'] = $calc_discount['discount']; $fields['discountids'] = $calc_discount['discountids']; @@ -764,8 +764,8 @@ function eme_update_member_discount( $member ) { $calc_discount = eme_member_discount( $membership, $member ); $members_table = $eme_db_prefix . MEMBERS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['member_id'] = $member['member_id']; $fields['discount'] = $calc_discount['discount']; $fields['discountids'] = $calc_discount['discountids']; @@ -785,7 +785,7 @@ function eme_update_member_discount( $member ) { function eme_discounts_edit_layout( $discount_id = 0, $message = '' ) { global $plugin_page; - $selected_dgroup_arr = array(); + $selected_dgroup_arr = []; if ( $discount_id ) { $discount = eme_get_discount( $discount_id ); $selected_dgroup = $discount['dgroup']; @@ -796,9 +796,9 @@ function eme_discounts_edit_layout( $discount_id = 0, $message = '' ) { $dgroup = eme_get_discountgroup_by_name( $selected_dgroup ); // take the case where the group no longer exists into account if ( ! empty( $dgroup ) ) { - $selected_dgroup_arr = array( $dgroup['id'] ); + $selected_dgroup_arr = [ $dgroup['id'] ]; } else { - $selected_dgroup_arr = array(); + $selected_dgroup_arr = []; } } } @@ -1072,7 +1072,7 @@ function eme_db_update_discount( $id, $line ) { if ( ! eme_is_serialized( $new_line['properties'] ) ) { $new_line['properties'] = eme_serialize( $new_line['properties'] ); } - $where = array( 'id' => $id ); + $where = [ 'id' => $id ]; if ( isset( $new_line['id'] ) ) { unset( $new_line['id'] ); } @@ -1106,7 +1106,7 @@ function eme_db_update_dgroup( $id, $line ) { // we only want the columns that interest us $keys = array_intersect_key( $line, $discountgroup ); $new_line = array_merge( $discountgroup, $keys ); - $where = array( 'id' => $id ); + $where = [ 'id' => $id ]; if ( isset( $new_line['id'] ) ) { unset( $new_line['id'] ); } @@ -1396,7 +1396,7 @@ function eme_calc_booking_discount( $discount, $booking ) { } } } - return array( $discount_calculated, $dcodes_used ); + return [ $discount_calculated, $dcodes_used ]; } function eme_calc_booking_single_discount( $discount, $booking, $coupon = '' ) { @@ -1524,7 +1524,7 @@ function eme_calc_member_discount( $discount, $member ) { } } } - return array( $discount_calculated, $dcodes_used ); + return [ $discount_calculated, $dcodes_used ]; } function eme_calc_member_single_discount( $discount, $member, $coupon = '' ) { @@ -1546,12 +1546,12 @@ function eme_calc_member_single_discount( $discount, $member, $coupon = '' ) { } function eme_get_discounttypes() { - $types = array( + $types = [ EME_DISCOUNT_TYPE_FIXED => __( 'Fixed', 'events-made-easy' ), EME_DISCOUNT_TYPE_PCT => __( 'Percentage', 'events-made-easy' ), EME_DISCOUNT_TYPE_CODE => __( 'Code', 'events-made-easy' ), EME_DISCOUNT_TYPE_FIXED_PER_SEAT => __( 'Fixed per seat', 'events-made-easy' ), - ); + ]; return $types; } @@ -1573,12 +1573,12 @@ function eme_ajax_discounts_list() { global $wpdb,$eme_db_prefix, $eme_timezone; check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); $table = $eme_db_prefix . DISCOUNTS_TBNAME; - $jTableResult = array(); + $jTableResult = []; // The toolbar search input $q = isset( $_REQUEST['q'] ) ? eme_sanitize_request($_REQUEST['q']) : ''; $opt = isset( $_REQUEST['opt'] ) ? eme_sanitize_request($_REQUEST['opt']) : ''; $where = ''; - $where_array = array(); + $where_array = []; if ( $q ) { for ( $i = 0; $i < count( $opt ); $i++ ) { $fld = esc_sql( $opt[ $i ] ); @@ -1603,7 +1603,7 @@ function eme_ajax_discounts_list() { $selected_dgroup = $row['dgroup']; // let's see if the dgroup is an csv of integers, if so: convert to names $selected_dgroup_arr = explode( ',', $selected_dgroup ); - $res_arr = array(); + $res_arr = []; if ( eme_array_integers( $selected_dgroup_arr ) ) { foreach ( $selected_dgroup_arr as $dgroup_id ) { $dgroup = eme_get_discountgroup( $dgroup_id ); @@ -1652,12 +1652,12 @@ function eme_ajax_discountgroups_list() { global $wpdb,$eme_db_prefix; check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); $table = $eme_db_prefix . DISCOUNTGROUPS_TBNAME; - $jTableResult = array(); + $jTableResult = []; // The toolbar search input $q = isset( $_REQUEST['q'] ) ? eme_sanitize_request($_REQUEST['q']) : ''; $opt = isset( $_REQUEST['opt'] ) ? eme_sanitize_request($_REQUEST['opt']) : ''; $where = ''; - $where_array = array(); + $where_array = []; if ( $q ) { for ( $i = 0; $i < count( $opt ); $i++ ) { $fld = esc_sql( $opt[ $i ] ); @@ -1699,7 +1699,7 @@ function eme_ajax_discounts_select2() { wp_die(); } $table = $eme_db_prefix . DISCOUNTS_TBNAME; - $jTableResult = array(); + $jTableResult = []; $q = isset( $_REQUEST['q'] ) ? strtolower( eme_sanitize_request( $_REQUEST['q'] ) ) : ''; if ( ! empty( $q ) ) { $where = "(name LIKE '%" . esc_sql( $wpdb->esc_like( $q ) ) . "%')"; @@ -1713,10 +1713,10 @@ function eme_ajax_discounts_select2() { $recordCount = $wpdb->get_var( $count_sql ); $search = "$where ORDER BY name LIMIT $start,$pagesize"; - $records = array(); + $records = []; $discounts = eme_get_discounts( '', $search ); foreach ( $discounts as $discount ) { - $record = array(); + $record = []; $record['id'] = $discount['id']; // no eme_esc_html here, select2 does it own escaping upon arrival $record['text'] = $discount['name']; @@ -1735,7 +1735,7 @@ function eme_ajax_dgroups_select2() { wp_die(); } $table = $eme_db_prefix . DISCOUNTGROUPS_TBNAME; - $jTableResult = array(); + $jTableResult = []; $q = isset( $_REQUEST['q'] ) ? strtolower( eme_sanitize_request( $_REQUEST['q'] ) ) : ''; if ( ! empty( $q ) ) { $where = "(name LIKE '%" . esc_sql( $wpdb->esc_like( $q ) ) . "%')"; @@ -1749,10 +1749,10 @@ function eme_ajax_dgroups_select2() { $recordCount = $wpdb->get_var( $count_sql ); $search = "$where ORDER BY name LIMIT $start,$pagesize"; - $records = array(); + $records = []; $dgroups = eme_get_dgroups( '', $search ); foreach ( $dgroups as $dgroup ) { - $record = array(); + $record = []; $record['id'] = $dgroup['id']; // no eme_esc_html here, select2 does it own escaping upon arrival $record['text'] = $dgroup['name']; @@ -1769,7 +1769,7 @@ function eme_ajax_manage_discounts() { if (! current_user_can( get_option( 'eme_cap_discounts' ) ) ) { wp_die(); } - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'OK'; if ( isset( $_REQUEST['do_action'] ) ) { $do_action = eme_sanitize_request( $_REQUEST['do_action'] ); @@ -1829,7 +1829,7 @@ function eme_ajax_manage_discountgroups() { if (! current_user_can( get_option( 'eme_cap_discounts' ) ) ) { wp_die(); } - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'OK'; if ( isset( $_REQUEST['do_action'] ) ) { $do_action = eme_sanitize_request( $_REQUEST['do_action'] ); diff --git a/eme-events.php b/eme-events.php index 3c24bb10..e5ac4fb9 100644 --- a/eme-events.php +++ b/eme-events.php @@ -9,7 +9,7 @@ function eme_new_event() { $eme_date_obj = new ExpressiveDate( 'now', $eme_timezone ); $today = $eme_date_obj->getDate(); $this_datetime = $eme_date_obj->getDateTime(); - $event = array( + $event = [ 'event_name' => '', 'event_status' => get_option( 'eme_event_initial_state' ), 'event_start' => $this_datetime, @@ -28,7 +28,7 @@ function eme_new_event() { 'event_author' => 0, 'event_contactperson_id' => get_option( 'eme_default_contact_person' ), 'event_category_ids' => '', - 'event_attributes' => array(), + 'event_attributes' => [], 'event_page_title_format' => '', 'event_single_event_format' => '', 'event_contactperson_email_body' => '', @@ -48,13 +48,13 @@ function eme_new_event() { 'event_external_ref' => '', 'event_url' => '', 'recurrence_id' => 0, - ); + ]; // while in EME itself event_image_url can't be set when defining an event, it can be set in the frontend submit or a sync plugin $event['event_properties'] = eme_init_event_props(); return $event; } -function eme_init_event_props( $props = array() ) { +function eme_init_event_props( $props = [] ) { if ( ! isset( $props['create_wp_user'] ) ) { $props['create_wp_user'] = 0; } @@ -121,7 +121,7 @@ function eme_init_event_props( $props = array() ) { $props['rsvp_discountgroup'] = ''; } if ( ! isset( $props['rsvp_addpersontogroup'] ) ) { - $props['rsvp_addpersontogroup'] = array(); + $props['rsvp_addpersontogroup'] = []; } if ( ! isset( $props['rsvp_password'] ) ) { $props['rsvp_password'] = ''; @@ -211,24 +211,24 @@ function eme_init_event_props( $props = array() ) { $props['rsvp_approved_reminder_days'] = get_option( 'eme_rsvp_approved_reminder_days' ); } - $template_override = array( 'event_page_title_format_tpl', 'event_single_event_format_tpl', 'event_contactperson_email_body_tpl', 'event_registration_recorded_ok_html_tpl', 'event_respondent_email_body_tpl', 'event_registration_pending_email_body_tpl', 'event_registration_userpending_email_body_tpl', 'event_registration_updated_email_body_tpl', 'event_registration_cancelled_email_body_tpl', 'event_registration_trashed_email_body_tpl', 'event_registration_form_format_tpl', 'event_cancel_form_format_tpl', 'event_registration_paid_email_body_tpl', 'event_contactperson_email_subject_tpl', 'event_respondent_email_subject_tpl', 'event_registration_pending_email_subject_tpl', 'event_registration_userpending_email_subject_tpl', 'event_registration_updated_email_subject_tpl', 'event_registration_cancelled_email_subject_tpl', 'event_registration_trashed_email_subject_tpl', 'event_registration_paid_email_subject_tpl', 'contactperson_registration_pending_email_subject_tpl', 'contactperson_registration_pending_email_body_tpl', 'contactperson_registration_cancelled_email_subject_tpl', 'contactperson_registration_cancelled_email_body_tpl', 'contactperson_registration_ipn_email_subject_tpl', 'contactperson_registration_ipn_email_body_tpl', 'contactperson_registration_paid_email_subject_tpl', 'contactperson_registration_paid_email_body_tpl', 'attendance_unauth_scan_tpl', 'attendance_auth_scan_tpl', 'task_signup_email_subject_tpl', 'task_signup_email_body_tpl', 'cp_task_signup_email_subject_tpl', 'cp_task_signup_email_body_tpl', 'task_signup_pending_email_subject_tpl', 'task_signup_pending_email_body_tpl', 'cp_task_signup_pending_email_subject_tpl', 'cp_task_signup_pending_email_body_tpl', 'task_signup_updated_email_subject_tpl', 'task_signup_updated_email_body_tpl', 'task_signup_cancelled_email_subject_tpl', 'task_signup_cancelled_email_body_tpl', 'cp_task_signup_cancelled_email_subject_tpl', 'cp_task_signup_cancelled_email_body_tpl', 'task_signup_trashed_email_subject_tpl', 'task_signup_trashed_email_body_tpl', 'task_signup_form_format_tpl', 'task_signup_recorded_ok_html_tpl', 'task_signup_reminder_email_subject_tpl', 'task_signup_reminder_email_body_tpl', 'event_registration_reminder_email_subject_tpl', 'event_registration_reminder_email_body_tpl', 'event_registration_pending_reminder_email_subject_tpl', 'event_registration_pending_reminder_email_body_tpl' ); + $template_override = [ 'event_page_title_format_tpl', 'event_single_event_format_tpl', 'event_contactperson_email_body_tpl', 'event_registration_recorded_ok_html_tpl', 'event_respondent_email_body_tpl', 'event_registration_pending_email_body_tpl', 'event_registration_userpending_email_body_tpl', 'event_registration_updated_email_body_tpl', 'event_registration_cancelled_email_body_tpl', 'event_registration_trashed_email_body_tpl', 'event_registration_form_format_tpl', 'event_cancel_form_format_tpl', 'event_registration_paid_email_body_tpl', 'event_contactperson_email_subject_tpl', 'event_respondent_email_subject_tpl', 'event_registration_pending_email_subject_tpl', 'event_registration_userpending_email_subject_tpl', 'event_registration_updated_email_subject_tpl', 'event_registration_cancelled_email_subject_tpl', 'event_registration_trashed_email_subject_tpl', 'event_registration_paid_email_subject_tpl', 'contactperson_registration_pending_email_subject_tpl', 'contactperson_registration_pending_email_body_tpl', 'contactperson_registration_cancelled_email_subject_tpl', 'contactperson_registration_cancelled_email_body_tpl', 'contactperson_registration_ipn_email_subject_tpl', 'contactperson_registration_ipn_email_body_tpl', 'contactperson_registration_paid_email_subject_tpl', 'contactperson_registration_paid_email_body_tpl', 'attendance_unauth_scan_tpl', 'attendance_auth_scan_tpl', 'task_signup_email_subject_tpl', 'task_signup_email_body_tpl', 'cp_task_signup_email_subject_tpl', 'cp_task_signup_email_body_tpl', 'task_signup_pending_email_subject_tpl', 'task_signup_pending_email_body_tpl', 'cp_task_signup_pending_email_subject_tpl', 'cp_task_signup_pending_email_body_tpl', 'task_signup_updated_email_subject_tpl', 'task_signup_updated_email_body_tpl', 'task_signup_cancelled_email_subject_tpl', 'task_signup_cancelled_email_body_tpl', 'cp_task_signup_cancelled_email_subject_tpl', 'cp_task_signup_cancelled_email_body_tpl', 'task_signup_trashed_email_subject_tpl', 'task_signup_trashed_email_body_tpl', 'task_signup_form_format_tpl', 'task_signup_recorded_ok_html_tpl', 'task_signup_reminder_email_subject_tpl', 'task_signup_reminder_email_body_tpl', 'event_registration_reminder_email_subject_tpl', 'event_registration_reminder_email_body_tpl', 'event_registration_pending_reminder_email_subject_tpl', 'event_registration_pending_reminder_email_body_tpl' ]; foreach ( $template_override as $line ) { if ( ! isset( $props[ $line ] ) ) { $props[ $line ] = 0; } } - $text_override = array( 'event_contactperson_email_subject', 'event_respondent_email_subject', 'event_registration_pending_email_subject', 'event_registration_userpending_email_subject', 'event_registration_userpending_email_body', 'event_registration_updated_email_subject', 'event_registration_cancelled_email_subject', 'event_registration_paid_email_subject', 'event_registration_trashed_email_subject', 'contactperson_registration_pending_email_body', 'contactperson_registration_cancelled_email_body', 'contactperson_registration_ipn_email_body', 'contactperson_registration_pending_email_subject', 'contactperson_registration_cancelled_email_subject', 'contactperson_registration_ipn_email_subject', 'contactperson_registration_paid_email_subject', 'contactperson_registration_paid_email_body', 'attendance_unauth_scan_format', 'attendance_auth_scan_format', 'event_registration_reminder_email_subject', 'event_registration_reminder_email_body', 'event_registration_pending_reminder_email_subject', 'event_registration_pending_reminder_email_body' ); + $text_override = [ 'event_contactperson_email_subject', 'event_respondent_email_subject', 'event_registration_pending_email_subject', 'event_registration_userpending_email_subject', 'event_registration_userpending_email_body', 'event_registration_updated_email_subject', 'event_registration_cancelled_email_subject', 'event_registration_paid_email_subject', 'event_registration_trashed_email_subject', 'contactperson_registration_pending_email_body', 'contactperson_registration_cancelled_email_body', 'contactperson_registration_ipn_email_body', 'contactperson_registration_pending_email_subject', 'contactperson_registration_cancelled_email_subject', 'contactperson_registration_ipn_email_subject', 'contactperson_registration_paid_email_subject', 'contactperson_registration_paid_email_body', 'attendance_unauth_scan_format', 'attendance_auth_scan_format', 'event_registration_reminder_email_subject', 'event_registration_reminder_email_body', 'event_registration_pending_reminder_email_subject', 'event_registration_pending_reminder_email_body' ]; foreach ( $text_override as $line ) { if ( ! isset( $props[ $line ] ) ) { $props[ $line ] = ''; } } // for renamed properties - $renamed_props = array( + $renamed_props = [ 'event_registration_denied_email_body_tpl' => 'event_registration_trashed_email_body_tpl', 'event_registration_denied_email_subject_tpl' => 'event_registration_trashed_email_subject_tpl', 'event_registration_denied_email_subject' => 'event_registration_trashed_email_subject', - ); + ]; foreach ( $renamed_props as $old_prop => $new_prop ) { if ( isset( $props[ $old_prop ] ) ) { $props[ $new_prop ] = $props[ $old_prop ]; @@ -243,7 +243,7 @@ function eme_events_page() { global $wpdb,$eme_db_prefix, $eme_timezone, $eme_wp_time_format; $press_back = __( 'Press the back-button in your browser to return to the previous screen and correct your errors', 'events-made-easy' ); - $extra_conditions = array(); + $extra_conditions = []; if ( isset( $_POST['eme_admin_action'] ) ) { $action = eme_sanitize_request( $_POST['eme_admin_action'] ); $event_ID = isset( $_POST['event_id'] ) ? eme_sanitize_request( $_POST['event_id'] ) : 0; @@ -350,7 +350,7 @@ function eme_events_page() { } } $orig_event = $event; - $post_vars = array( 'event_name', 'event_seats', 'price', 'rsvp_number_days', 'rsvp_number_hours', 'currency', 'event_author', 'event_contactperson_id', 'event_url', 'event_image_url', 'event_image_id', 'event_prefix', 'event_slug', 'event_page_title_format', 'event_contactperson_email_body', 'event_registration_recorded_ok_html', 'event_respondent_email_body', 'event_registration_pending_email_body', 'event_registration_updated_email_body', 'event_registration_cancelled_email_body', 'event_registration_trashed_email_body', 'event_registration_form_format', 'event_cancel_form_format', 'event_registration_paid_email_body' ); + $post_vars = [ 'event_name', 'event_seats', 'price', 'rsvp_number_days', 'rsvp_number_hours', 'currency', 'event_author', 'event_contactperson_id', 'event_url', 'event_image_url', 'event_image_id', 'event_prefix', 'event_slug', 'event_page_title_format', 'event_contactperson_email_body', 'event_registration_recorded_ok_html', 'event_respondent_email_body', 'event_registration_pending_email_body', 'event_registration_updated_email_body', 'event_registration_cancelled_email_body', 'event_registration_trashed_email_body', 'event_registration_form_format', 'event_cancel_form_format', 'event_registration_paid_email_body' ]; foreach ( $post_vars as $post_var ) { if ( isset( $_POST[ $post_var ] ) ) { $event[ $post_var ] = eme_kses( $_POST[ $post_var ] ); @@ -358,7 +358,7 @@ function eme_events_page() { } // now for the select boxes, we need to set to 0 if not in the _POST - $select_post_vars = array( 'event_tasks', 'event_rsvp', 'registration_requires_approval', 'registration_wp_users_only' ); + $select_post_vars = [ 'event_tasks', 'event_rsvp', 'registration_requires_approval', 'registration_wp_users_only' ]; foreach ( $select_post_vars as $post_var ) { if ( isset( $_POST[ $post_var ] ) ) { $event[ $post_var ] = intval( $_POST[ $post_var ] ); @@ -449,7 +449,7 @@ function eme_events_page() { $recurrence['holidays_id'] = isset( $_POST['holidays_id'] ) ? intval( $_POST['holidays_id'] ) : 0; // set the location info - $post_vars = array( 'location_name', 'location_address1', 'location_address2', 'location_city', 'location_state', 'location_zip', 'location_country', 'location_latitude', 'location_longitude', 'location_url' ); + $post_vars = [ 'location_name', 'location_address1', 'location_address2', 'location_city', 'location_state', 'location_zip', 'location_country', 'location_latitude', 'location_longitude', 'location_url' ]; foreach ( $post_vars as $post_var ) { if ( isset( $_POST[ $post_var ] ) ) { $location[ $post_var ] = eme_sanitize_request( $_POST[ $post_var ] ); @@ -463,7 +463,7 @@ function eme_events_page() { } // set the attributes - $event_attributes = array(); + $event_attributes = []; for ( $i = 1; isset( $_POST[ "eme_attr_{$i}_ref" ] ) && trim( $_POST[ "eme_attr_{$i}_ref" ] ) != ''; $i++ ) { if ( trim( $_POST[ "eme_attr_{$i}_name" ] ) != '' ) { $event_attributes[ $_POST[ "eme_attr_{$i}_ref" ] ] = eme_kses( $_POST[ "eme_attr_{$i}_name" ] ); @@ -472,9 +472,9 @@ function eme_events_page() { $event['event_attributes'] = $event_attributes; // set the properties for both event and location - $event_properties = array(); + $event_properties = []; $event_properties = eme_init_event_props( $event_properties ); - $location_properties = array(); + $location_properties = []; $location_properties = eme_init_location_props( $location_properties ); // now for the select boxes, we need to set to 0 if not in the _POST $payment_gateways = eme_payment_gateways(); @@ -484,7 +484,7 @@ function eme_events_page() { $event_properties[ 'use_' . $pg ] = 0; } } - $select_event_post_vars = array( 'use_captcha', 'use_recaptcha', 'use_hcaptcha', 'dyndata_all_fields', 'all_day' ); + $select_event_post_vars = [ 'use_captcha', 'use_recaptcha', 'use_hcaptcha', 'dyndata_all_fields', 'all_day' ]; foreach ( $select_event_post_vars as $post_var ) { if ( ! isset( $_POST[ 'eme_prop_' . $post_var ] ) ) { $event_properties[ $post_var ] = 0; @@ -493,7 +493,7 @@ function eme_events_page() { if ( $event_properties['use_captcha'] && ! function_exists( 'imagecreatetruecolor' ) ) { $event_properties['use_captcha'] = 0; } - $select_location_post_vars = array( 'online_only' ); + $select_location_post_vars = [ 'online_only' ]; foreach ( $select_location_post_vars as $post_var ) { if ( ! isset( $_POST[ 'eme_loc_prop_' . $post_var ] ) ) { $location_properties[ $post_var ] = 0; @@ -504,7 +504,7 @@ function eme_events_page() { if ( preg_match( '/eme_prop_(.+)/', eme_sanitize_request( $key ), $matches ) ) { $found_key = $matches[1]; if ( $found_key == 'multiprice_desc' ) { - $event_properties[ $found_key ] = join( '||', eme_sanitize_request( eme_text_split_newlines( $_POST[ $key ] ) ) ); + $event_properties[ $found_key ] = join( '||', eme_sanitize_request( eme_text_split_newlines( $value ) ) ); } else { $event_properties[ $found_key ] = eme_kses( $value ); } @@ -578,7 +578,7 @@ function eme_events_page() { $count = eme_recurrence_count( $recurrence_id ); $feedback_message = sprintf( __( 'New recurrence inserted containing %d events', 'events-made-easy' ), $count ); if ( $stay_on_edit_page ) { - $info = array( 'title' => __( 'Edit Recurrence', 'events-made-easy' ) ); + $info = [ 'title' => __( 'Edit Recurrence', 'events-made-easy' ) ]; $info['feedback'] = $feedback_message; $event = eme_get_event( eme_get_recurrence_first_eventid( $recurrence_id ) ); if ( ! empty( $event ) ) { @@ -601,7 +601,7 @@ function eme_events_page() { } $feedback_message = __( 'New event successfully inserted!', 'events-made-easy' ); if ( $stay_on_edit_page ) { - $info = array( 'title' => sprintf( __( "Edit Event '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ) ); + $info = [ 'title' => sprintf( __( "Edit Event '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ) ]; $info['feedback'] = $feedback_message; $event = eme_get_event( $event_id ); if ( ! empty( $event ) ) { @@ -622,7 +622,7 @@ function eme_events_page() { if ( $count ) { $feedback_message = sprintf( __( 'Recurrence updated, contains %d events', 'events-made-easy' ), $count ); if ( $stay_on_edit_page ) { - $info = array( 'title' => __( 'Edit Recurrence', 'events-made-easy' ) ); + $info = [ 'title' => __( 'Edit Recurrence', 'events-made-easy' ) ]; $info['feedback'] = $feedback_message; $event = eme_get_event( eme_get_recurrence_first_eventid( $recurrence_ID ) ); if ( ! empty( $event ) ) { @@ -649,7 +649,7 @@ function eme_events_page() { $count = eme_recurrence_count( $recurrence_id ); $feedback_message = sprintf( __( 'New recurrent event inserted containing %d events', 'events-made-easy' ), $count ); if ( $stay_on_edit_page ) { - $info = array( 'title' => __( 'Edit Recurrence', 'events-made-easy' ) ); + $info = [ 'title' => __( 'Edit Recurrence', 'events-made-easy' ) ]; $info['feedback'] = $feedback_message; $event = eme_get_event( eme_get_recurrence_first_eventid( $recurrence_id ) ); if ( ! empty( $event ) ) { @@ -670,7 +670,7 @@ function eme_events_page() { } $feedback_message = sprintf( __( "Updated '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ); if ( $stay_on_edit_page ) { - $info = array( 'title' => sprintf( __( "Edit Event '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ) ); + $info = [ 'title' => sprintf( __( "Edit Event '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ) ]; $info['feedback'] = $feedback_message; $event = eme_get_event( $event_ID ); if ( ! empty( $event ) ) { @@ -700,7 +700,7 @@ function eme_events_page() { if ( $action == 'add_new_event' ) { if ( current_user_can( get_option( 'eme_cap_add_event' ) ) ) { $event = eme_new_event(); - $info = array( 'title' => __( 'Insert New Event', 'events-made-easy' ) ); + $info = [ 'title' => __( 'Insert New Event', 'events-made-easy' ) ]; eme_event_form( $event, $info ); } else { $feedback_message = __( 'You have no right to add events!', 'events-made-easy' ); @@ -712,7 +712,7 @@ function eme_events_page() { if ( $action == 'add_new_recurrence' ) { if ( current_user_can( get_option( 'eme_cap_add_event' ) ) ) { $event = eme_new_event(); - $info = array( 'title' => __( 'Insert New Recurrence', 'events-made-easy' ) ); + $info = [ 'title' => __( 'Insert New Recurrence', 'events-made-easy' ) ]; eme_event_form( $event, $info, 1 ); } else { $feedback_message = __( 'You have no right to add events!', 'events-made-easy' ); @@ -729,7 +729,7 @@ function eme_events_page() { } elseif ( current_user_can( get_option( 'eme_cap_edit_events' ) ) || ( current_user_can( get_option( 'eme_cap_author_event' ) ) && $event['event_author'] == $current_userid ) ) { // UPDATE event - $info = array( 'title' => sprintf( __( "Edit Event '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ) ); + $info = [ 'title' => sprintf( __( "Edit Event '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ) ]; eme_event_form( $event, $info ); } else { $feedback_message = sprintf( __( "You have no right to update '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ); @@ -752,7 +752,7 @@ function eme_events_page() { if ( current_user_can( get_option( 'eme_cap_edit_events' ) ) || ( current_user_can( get_option( 'eme_cap_author_event' ) ) && $event['event_author'] == $current_userid ) ) { - $info = array( 'title' => sprintf( __( "Edit event copy '%s'", 'events-made-easy' ), $event['event_name'] ) ); + $info = [ 'title' => sprintf( __( "Edit event copy '%s'", 'events-made-easy' ), $event['event_name'] ) ]; eme_event_form( $event, $info ); } else { $feedback_message = sprintf( __( "You have no right to copy '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ); @@ -773,7 +773,7 @@ function eme_events_page() { if ( current_user_can( get_option( 'eme_cap_edit_events' ) ) || ( current_user_can( get_option( 'eme_cap_author_event' ) ) && $event['event_author'] == $current_userid ) ) { - $info = array( 'title' => sprintf( __( "Edit recurrence copy '%s'", 'events-made-easy' ), $event['event_name'] ) ); + $info = [ 'title' => sprintf( __( "Edit recurrence copy '%s'", 'events-made-easy' ), $event['event_name'] ) ]; eme_event_form( $event, $info, 1 ); } else { $feedback_message = sprintf( __( "You have no right to copy '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ); @@ -791,7 +791,7 @@ function eme_events_page() { } if ( current_user_can( get_option( 'eme_cap_edit_events' ) ) || ( current_user_can( get_option( 'eme_cap_author_event' ) ) && $event['event_author'] == $current_userid ) ) { - $info = array( 'title' => __( 'Edit Recurrence', 'events-made-easy' ) . " '" . eme_translate( $event['event_name'] ) . "'" ); + $info = [ 'title' => __( 'Edit Recurrence', 'events-made-easy' ) . " '" . eme_translate( $event['event_name'] ) . "'" ]; eme_event_form( $event, $info, 1 ); } else { $feedback_message = sprintf( __( "You have no right to update '%s'", 'events-made-easy' ), eme_translate( $event['event_name'] ) ); @@ -818,7 +818,7 @@ function eme_get_all_pages() { $pages = $wpdb->get_results( $query, ARRAY_A ); // get_pages() is better, but uses way more memory and it might be filtered by eme_filter_get_pages() //$pages = get_pages(); - $output = array(); + $output = []; $output[] = __( 'Please select a page', 'events-made-easy' ); foreach ( $pages as $page ) { $output[ $page['id'] ] = $page['post_title']; @@ -846,7 +846,7 @@ function eme_events_page_content() { } } elseif ( ! empty( $_GET['eme_unsub'] ) ) { // lets act as if the unsub shortcode is on the page - $atts = array(); + $atts = []; return eme_unsubform_shortcode( $atts ); } elseif ( ! empty( $_GET['eme_sub_confirm'] ) && ! empty( $_GET['eme_sub_nonce'] ) ) { @@ -857,11 +857,11 @@ function eme_events_page_content() { $eme_email_groups = eme_sanitize_request( $_GET['g'] ); $eme_email_groups_arr = explode( ',', $eme_email_groups ); if ( ! eme_array_integers( $eme_email_groups_arr ) ) { - $eme_email_groups_arr = array(); + $eme_email_groups_arr = []; } } else { $eme_email_groups = ''; - $eme_email_groups_arr = array(); + $eme_email_groups_arr = []; } if ( wp_verify_nonce( eme_sanitize_request( $_GET['eme_sub_nonce'] ), "sub $eme_lastname$eme_firstname$eme_email$eme_email_groups" ) ) { $res = eme_sub_do( $eme_lastname, $eme_firstname, $eme_email, $eme_email_groups_arr ); @@ -879,11 +879,11 @@ function eme_events_page_content() { $eme_email_groups = eme_sanitize_request( $_GET['g'] ); $eme_email_groups_arr = explode( ',', $eme_email_groups ); if ( ! eme_array_integers( $eme_email_groups_arr ) ) { - $eme_email_groups_arr = array(); + $eme_email_groups_arr = []; } } else { $eme_email_groups = ''; - $eme_email_groups_arr = array(); + $eme_email_groups_arr = []; } if ( wp_verify_nonce( eme_sanitize_request( $_GET['eme_unsub_nonce'] ), "unsub $eme_email$eme_email_groups" ) ) { eme_unsub_do( $eme_email, $eme_email_groups_arr ); @@ -1343,7 +1343,7 @@ function eme_events_page_content() { function eme_events_count_for( $date ) { global $wpdb,$eme_db_prefix; $table_name = $eme_db_prefix . EVENTS_TBNAME; - $conditions = array(); + $conditions = []; if ( ! eme_is_admin_request() ) { if ( is_user_logged_in() ) { $conditions[] = 'event_status IN (' . EME_EVENT_STATUS_PUBLIC . ',' . EME_EVENT_STATUS_PRIVATE . ')'; @@ -1636,7 +1636,7 @@ function eme_filter_comments_array_access( $data, $post_id ) { if ( $access_allowed ) { return $data; } else { - $empty_arr = array(); + $empty_arr = []; return $empty_arr; } } @@ -1717,11 +1717,11 @@ function eme_template_redir() { if ( eme_is_serialized( $eme_memberships ) ) { $page_membershipids = eme_unserialize( $eme_memberships ); } else { - $page_membershipids = array(); + $page_membershipids = []; } if ( ! empty( $page_membershipids ) ) { $page_permalink = get_permalink(); - $redir_url = add_query_arg( array( 'redirect' => $page_permalink ), $redir_url ); + $redir_url = add_query_arg( [ 'redirect' => $page_permalink ], $redir_url ); eme_nocache_headers(); wp_redirect( esc_url( $redir_url ) ); exit; @@ -1746,7 +1746,7 @@ function eme_template_redir() { $redir_url = get_option( 'eme_redir_priv_event_url' ); if ( ! empty( $redir_url ) ) { $page_permalink = get_permalink(); - $redir_url = add_query_arg( array( 'redirect' => $page_permalink ), $redir_url ); + $redir_url = add_query_arg( [ 'redirect' => $page_permalink ], $redir_url ); eme_nocache_headers(); wp_redirect( esc_url( $redir_url ) ); exit; @@ -1846,7 +1846,7 @@ function eme_template_redir() { // remove yoast SEO from the header, EME generates it's own one if ( function_exists( 'YoastSEO' ) ) { $front_end = YoastSEO()->classes->get( Yoast\WP\SEO\Integrations\Front_End_Integration::class ); - remove_action( 'wpseo_head', array( $front_end, 'present_head' ), -9999 ); + remove_action( 'wpseo_head', [ $front_end, 'present_head' ], -9999 ); } } } @@ -2790,7 +2790,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } } elseif ( $event && preg_match( '/#_EVENTIMAGE$/', $result ) ) { if ( ! empty( $event['event_image_id'] ) ) { - $replacement = wp_get_attachment_image( $event['event_image_id'], 'full', 0, array( 'class' => 'eme_event_image' ) ); + $replacement = wp_get_attachment_image( $event['event_image_id'], 'full', 0, [ 'class' => 'eme_event_image' ] ); } elseif ( ! empty( $event['event_image_url'] ) ) { $url = $event['event_image_url']; if ( $target == 'html' ) { @@ -2818,7 +2818,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } } elseif ( $event && preg_match( '/#_EVENTIMAGETHUMB$/', $result ) ) { if ( ! empty( $event['event_image_id'] ) ) { - $replacement = wp_get_attachment_image( $event['event_image_id'], get_option( 'eme_thumbnail_size' ), 0, array( 'class' => 'eme_event_image' ) ); + $replacement = wp_get_attachment_image( $event['event_image_id'], get_option( 'eme_thumbnail_size' ), 0, [ 'class' => 'eme_event_image' ] ); if ( $target == 'html' ) { $replacement = apply_filters( 'eme_general', $replacement ); } elseif ( $target == 'rss' ) { @@ -2836,7 +2836,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } } elseif ( $event && preg_match( '/#_EVENTIMAGETHUMB\{(.+?)\}$/', $result, $matches ) ) { if ( ! empty( $event['event_image_id'] ) ) { - $replacement = wp_get_attachment_image( $event['event_image_id'], $matches[1], 0, array( 'class' => 'eme_event_image' ) ); + $replacement = wp_get_attachment_image( $event['event_image_id'], $matches[1], 0, [ 'class' => 'eme_event_image' ] ); if ( $target == 'html' ) { $replacement = apply_filters( 'eme_general', $replacement ); } elseif ( $target == 'rss' ) { @@ -2933,9 +2933,9 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } } elseif ( $event && preg_match( '/#_EVENTPAGEURL\{(.+?)\}$/', $result, $matches ) ) { $events_page_link = eme_get_events_page(); - $replacement = add_query_arg( array( 'event_id' => intval( $matches[1] ) ), $events_page_link ); + $replacement = add_query_arg( [ 'event_id' => intval( $matches[1] ) ], $events_page_link ); if ( ! empty( $lang ) ) { - $replacement = add_query_arg( array( 'lang' => $lang ), $replacement ); + $replacement = add_query_arg( [ 'lang' => $lang ], $replacement ); } if ( $target == 'html' ) { $replacement = esc_url( $replacement ); @@ -2971,7 +2971,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan $eme_date_obj = new ExpressiveDate( $event['event_end'], $eme_timezone ); } $diff = $eme_date_obj_now->diff( $eme_date_obj )->format( '%r1:%y:%m:%a:%h:%i:%s' ); - list($pos_neg,$years, $months,$days,$hours,$mins,$secs) = explode( ':', $diff ); + [$pos_neg, $years, $months, $days, $hours, $mins, $secs] = explode( ':', $diff ); if ( $matches[1] == 'TILL' && $pos_neg < 0 ) { $replacement = 0; } elseif ( $matches[1] == 'FROM' && $pos_neg > 0 ) { @@ -3382,7 +3382,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan if ( is_null( $event_categories ) ) { $event_categories = eme_get_categories_filtered( $event['event_category_ids'], $all_categories ); } - $cat_links = array(); + $cat_links = []; foreach ( $event_categories as $category ) { $cat_link = eme_category_url( $category ); $cat_name = $category['category_name']; @@ -3408,7 +3408,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } elseif ( $event && preg_match( '/^#_(EVENT)?CATEGORIES\{(.*?)\}\{(.*?)\}$/', $result, $matches ) && get_option( 'eme_categories_enabled' ) ) { $include_cats = $matches[2]; $exclude_cats = $matches[3]; - $extra_conditions_arr = array(); + $extra_conditions_arr = []; $order_by = ''; if ( ! empty( $include_cats ) && eme_list_of_int($include_cats) ) { array_push( $extra_conditions_arr, "category_id IN ($include_cats)" ); @@ -3419,7 +3419,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } $extra_conditions = join( ' AND ', $extra_conditions_arr ); $t_categories = eme_get_event_category_names( $event['event_id'], $extra_conditions, $order_by ); - $cat_names = array(); + $cat_names = []; foreach ( $t_categories as $cat_name ) { if ( $target == 'html' ) { array_push( $cat_names, eme_trans_esc_html( $cat_name, $lang ) ); @@ -3442,7 +3442,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } elseif ( $event && preg_match( '/^#_(EVENT)?CATEGORIES_CSS\{(.*?)\}\{(.*?)\}$/', $result, $matches ) && get_option( 'eme_categories_enabled' ) ) { $include_cats = $matches[2]; $exclude_cats = $matches[3]; - $extra_conditions_arr = array(); + $extra_conditions_arr = []; $order_by = ''; if ( ! empty( $include_cats ) && eme_list_of_int($include_cats) ) { array_push( $extra_conditions_arr, "category_id IN ($include_cats)" ); @@ -3466,7 +3466,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } elseif ( $event && preg_match( '/#_(EVENT)?CATEGORYDESCRIPTIONS\{(.*?)\}\{(.*?)\}$/', $result, $matches ) && get_option( 'eme_categories_enabled' ) ) { $include_cats = $matches[2]; $exclude_cats = $matches[3]; - $extra_conditions_arr = array(); + $extra_conditions_arr = []; $order_by = ''; if ( ! empty( $include_cats ) && eme_list_of_int($include_cats) ) { array_push( $extra_conditions_arr, "category_id IN ($include_cats)" ); @@ -3492,7 +3492,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } elseif ( $event && preg_match( '/#_LINKED(EVENT)?CATEGORIES\{(.*?)\}\{(.*?)\}$/', $result, $matches ) && get_option( 'eme_categories_enabled' ) ) { $include_cats = $matches[2]; $exclude_cats = $matches[3]; - $extra_conditions_arr = array(); + $extra_conditions_arr = []; $order_by = ''; if ( ! empty( $include_cats ) && eme_list_of_int($include_cats) ) { array_push( $extra_conditions_arr, "category_id IN ($include_cats)" ); @@ -3503,7 +3503,7 @@ function eme_replace_event_placeholders( $format, $event, $target = 'html', $lan } $extra_conditions = join( ' AND ', $extra_conditions_arr ); $t_categories = eme_get_event_categories( $event['event_id'], $extra_conditions, $order_by ); - $cat_links = array(); + $cat_links = []; foreach ( $t_categories as $category ) { $cat_link = eme_category_url( $category ); $cat_name = $category['category_name']; @@ -3968,7 +3968,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format if ( strpos( $limit, '=' ) ) { // allows the use of arguments without breaking the legacy code $eme_event_list_number_events = get_option( 'eme_event_list_number_items' ); - $defaults = array( + $defaults = [ 'limit' => $eme_event_list_number_events, 'scope' => $scope, 'order' => $order, @@ -3994,7 +3994,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format 'template_id_footer' => $template_id_footer, 'no_events_message' => $no_events_message, 'template_id_no_events' => $template_id_no_events, - ); + ]; $r = wp_parse_args( $limit, $defaults ); extract( $r ); // for AND categories: the user enters "+" and this gets translated to " " by wp_parse_args @@ -4038,7 +4038,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format // for registered users: we'll add a list of event_id's for that user only $extra_conditions = ''; - $extra_conditions_arr = array(); + $extra_conditions_arr = []; if ( $user_registered_only == 1 && is_user_logged_in() ) { $current_userid = get_current_user_id(); $list_of_event_ids_arr = eme_get_event_ids_for( $current_userid ); @@ -4173,7 +4173,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format $item = join( ',', $item ); } if ( ! empty( $item ) ) { - $this_page_url = add_query_arg( array( $key => $item ), $this_page_url ); + $this_page_url = add_query_arg( [ $key => $item ], $this_page_url ); } } } @@ -4186,9 +4186,9 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format if ( $backward < 0 ) { $pagination_top .= "<< $prev_text"; } else { - $pagination_top .= " $backward ), $this_page_url ) . "'><< $prev_text"; + $pagination_top .= " $backward ], $this_page_url ) . "'><< $prev_text"; } - $pagination_top .= " $forward ), $this_page_url ) . "'>$next_text >>"; + $pagination_top .= " $forward ], $this_page_url ) . "'>$next_text >>"; $pagination_top .= "" . sprintf( __( 'Page %d', 'events-made-easy' ), $page_number ) . ''; } if ( $events_count <= $limit && $limit_offset > 0 ) { @@ -4197,7 +4197,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format if ( $backward < 0 ) { $pagination_top .= "<< $prev_text"; } else { - $pagination_top .= " $backward ), $this_page_url ) . "'><< $prev_text"; + $pagination_top .= " $backward ], $this_page_url ) . "'><< $prev_text"; } $pagination_top .= "$next_text >>"; $pagination_top .= "" . sprintf( __( 'Page %d', 'events-made-easy' ), $page_number ) . ''; @@ -4226,7 +4226,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format $item = join( ',', $item ); } if ( ! empty( $item ) ) { - $this_page_url = add_query_arg( array( $key => $item ), $this_page_url ); + $this_page_url = add_query_arg( [ $key => $item ], $this_page_url ); } } } @@ -4236,13 +4236,13 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format $older_events = eme_get_events( 1, '--' . $limit_start, $order, 0, $location_id, $category, $author, $contact_person, $show_ongoing, $notcategory, $show_recurrent_events_once, $extra_conditions ); $newer_events = eme_get_events( 1, '++' . $limit_end, $order, 0, $location_id, $category, $author, $contact_person, $show_ongoing, $notcategory, $show_recurrent_events_once, $extra_conditions ); if ( count( $older_events ) > 0 ) { - $pagination_top .= " $prev_offset ), $this_page_url ) . "'><< $prev_text"; + $pagination_top .= " $prev_offset ], $this_page_url ) . "'><< $prev_text"; } else { $pagination_top .= "<< $prev_text"; } if ( count( $newer_events ) > 0 ) { - $pagination_top .= " $next_offset ), $this_page_url ) . "'>$next_text >>"; + $pagination_top .= " $next_offset ], $this_page_url ) . "'>$next_text >>"; } else { $pagination_top .= "$next_text >>"; } @@ -4280,7 +4280,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format } elseif ( $events_count > 0 ) { # we first need to determine on which days events occur # this code is identical to that in eme_calendar.php for "long events" - $eventful_days = array(); + $eventful_days = []; $event_counter = 1; foreach ( $events as $event ) { // we requested $limit+1 events, so we need to break at the $limit, if reached @@ -4299,7 +4299,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format if ( isset( $eventful_days[ $event_eventful_date ] ) && is_array( $eventful_days[ $event_eventful_date ] ) ) { $eventful_days[ $event_eventful_date ][] = $event; } else { - $eventful_days[ $event_eventful_date ] = array( $event ); + $eventful_days[ $event_eventful_date ] = [ $event ]; } $eme_date_obj_tmp->addOneDay(); } @@ -4309,7 +4309,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format if ( isset( $eventful_days[ $event_start_date ] ) && is_array( $eventful_days[ $event_start_date ] ) ) { $eventful_days[ $event_start_date ][] = $event; } else { - $eventful_days[ $event_start_date ] = array( $event ); + $eventful_days[ $event_start_date ] = [ $event ]; } } ++$event_counter; @@ -4321,7 +4321,7 @@ function eme_get_events_list( $limit, $scope = 'future', $order = 'ASC', $format $curday = ''; foreach ( $eventful_days as $day_key => $day_events ) { $eme_date_obj = new ExpressiveDate( $day_key, $eme_timezone ); - list($theyear, $themonth, $theday) = explode( '-', $eme_date_obj->getDate() ); + [$theyear, $themonth, $theday] = explode( '-', $eme_date_obj->getDate() ); if ( $showperiod == 'yearly' && $theyear != $curyear ) { $output .= "
  • " . eme_localized_date( $day_key, $eme_timezone, get_option( 'eme_show_period_yearly_dateformat' ) ) . '
  • '; } elseif ( $showperiod == 'monthly' && "$theyear$themonth" != "$curyear$curmonth" ) { @@ -4383,8 +4383,8 @@ function eme_get_events_list_shortcode( $atts ) { eme_enqueue_frontend(); $eme_event_list_number_events = get_option( 'eme_event_list_number_items' ); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'limit' => $eme_event_list_number_events, 'scope' => 'future', 'order' => 'ASC', @@ -4409,14 +4409,14 @@ function eme_get_events_list_shortcode( $atts ) { 'ignore_filter' => 0, 'offset' => 0, 'distance' => 0, - ), - $atts + ], + $atts ) ); $event_id = ''; - $event_id_arr = array(); - $location_id_arr = array(); + $event_id_arr = []; + $location_id_arr = []; // the filter list overrides the settings if ( ! $ignore_filter && isset( $_REQUEST['eme_eventAction'] ) && eme_sanitize_request( $_REQUEST['eme_eventAction']) == 'filter' ) { @@ -4564,13 +4564,13 @@ function eme_display_single_event( $event_id, $template_id = 0, $ignore_url = 0 function eme_display_single_event_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => '', 'template_id' => 0, 'ignore_url' => 0, - ), - $atts + ], + $atts ) ); return eme_display_single_event( $id, $template_id, $ignore_url ); @@ -4580,12 +4580,12 @@ function eme_get_events_page_shortcode( $atts ) { eme_enqueue_frontend(); // we don't want just the url, but the clickable link by default for the shortcode extract( - shortcode_atts( - array( + shortcode_atts( + [ 'justurl' => 0, 'text' => get_option( 'eme_events_page_title' ), - ), - $atts + ], + $atts ) ); $result = eme_get_events_page( $justurl, $text ); @@ -4613,7 +4613,7 @@ function eme_search_events( $name, $scope = 'future', $name_only = 0, $exclude_i $start_of_week = get_option( 'start_of_week' ); $eme_date_obj->setWeekStartDay( $start_of_week ); $now = $eme_date_obj->getDateTime(); - $where = array(); + $where = []; if ( $scope == 'past' ) { $where[] = "event_start < '$now'"; } elseif ( $scope == 'future' ) { @@ -4657,7 +4657,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off if ( strpos( $o_limit, '=' ) ) { // allows the use of arguments - $defaults = array( + $defaults = [ 'o_limit' => 0, 'scope' => $scope, 'order' => $order, @@ -4670,7 +4670,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off 'notcategory' => $notcategory, 'show_recurrent_events_once' => $show_recurrent_events_once, 'extra_conditions' => $extra_conditions, - ); + ]; $r = wp_parse_args( $o_limit, $defaults ); extract( $r ); @@ -4702,7 +4702,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off if ( $order == 'ASC' || $order == 'DESC' ) { $orderby = "ORDER BY event_start $order, event_name $order"; } elseif ( ! eme_is_empty_string( $order ) && preg_match( '/^[\w_\-\, ]+$/', $order ) ) { - $order_arr = array(); + $order_arr = []; $order_by = ''; if ( preg_match( '/^[\w_\-\, ]+$/', $order ) ) { $order_tmp_arr = explode( ',', $order ); @@ -4729,7 +4729,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off $this_time = $eme_date_obj->getTime(); $this_datetime = $eme_date_obj->getDateTime(); - $conditions = array(); + $conditions = []; // extra sql conditions we put in front, most of the time this is the most // effective place if ( $extra_conditions != '' ) { @@ -5095,7 +5095,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off $conditions[] = " $events_table.location_id = ''"; } elseif ( preg_match( '/,/', $location_id ) ) { $location_ids = explode( ',', $location_id ); - $location_conditions = array(); + $location_conditions = []; foreach ( $location_ids as $loc ) { if ( is_numeric( $loc ) && $loc > 0 ) { $location_conditions[] = "$events_table.location_id = $loc"; @@ -5107,7 +5107,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off } elseif ( preg_match( '/\+| /', $location_id ) ) { // url decoding of '+' is ' ' $location_ids = preg_split( '/\+| /', $location_id, 0, PREG_SPLIT_NO_EMPTY ); - $location_conditions = array(); + $location_conditions = []; foreach ( $location_ids as $loc ) { if ( is_numeric( $loc ) && $loc > 0 ) { $location_conditions[] = "$events_table.location_id = $loc"; @@ -5131,7 +5131,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off } } elseif ( preg_match( '/,/', $author ) ) { $authors = explode( ',', $author ); - $author_conditions = array(); + $author_conditions = []; foreach ( $authors as $authname ) { if ( is_numeric( $authname ) ) { $author_conditions[] = 'event_author = ' . $authname; @@ -5164,7 +5164,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off } } elseif ( preg_match( '/,/', $contact_person ) ) { $contact_persons = explode( ',', $contact_person ); - $contact_person_conditions = array(); + $contact_person_conditions = []; foreach ( $contact_persons as $authname ) { if ( is_numeric( $authname ) ) { $contact_person_conditions[] = "(event_contactperson_id = $authname OR (event_contactperson_id=-1 AND event_author=$authname))"; @@ -5191,7 +5191,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off $conditions[] = "event_category_ids = ''"; } elseif ( preg_match( '/,/', $category ) ) { $category = explode( ',', $category ); - $category_conditions = array(); + $category_conditions = []; foreach ( $category as $cat ) { if ( is_numeric( $cat ) && $cat > 0 ) { $category_conditions[] = "FIND_IN_SET($cat,event_category_ids)"; @@ -5202,7 +5202,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off $conditions[] = '(' . implode( ' OR ', $category_conditions ) . ')'; } elseif ( preg_match( '/\+| /', $category ) ) { $category = preg_split( '/\+| /', $category, 0, PREG_SPLIT_NO_EMPTY ); - $category_conditions = array(); + $category_conditions = []; foreach ( $category as $cat ) { if ( is_numeric( $cat ) && $cat > 0 ) { $category_conditions[] = "FIND_IN_SET($cat,event_category_ids)"; @@ -5219,7 +5219,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off $conditions[] = "event_category_ids != ''"; } elseif ( preg_match( '/,/', $notcategory ) ) { $notcategory = explode( ',', $notcategory ); - $category_conditions = array(); + $category_conditions = []; foreach ( $notcategory as $cat ) { if ( is_numeric( $cat ) && $cat > 0 ) { $category_conditions[] = "(NOT FIND_IN_SET($cat,event_category_ids) OR event_category_ids IS NULL)"; @@ -5231,7 +5231,7 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off } elseif ( preg_match( '/\+| /', $notcategory ) ) { // url decoding of '+' is ' ' $notcategory = preg_split( '/\+| /', $notcategory, 0, PREG_SPLIT_NO_EMPTY ); - $category_conditions = array(); + $category_conditions = []; foreach ( $notcategory as $cat ) { if ( is_numeric( $cat ) && $cat > 0 ) { $category_conditions[] = "(NOT FIND_IN_SET($cat,event_category_ids) OR event_category_ids IS NULL)"; @@ -5313,8 +5313,8 @@ function eme_get_events( $o_limit = 0, $scope = 'future', $order = 'ASC', $o_off return $count; } else { $events = $wpdb->get_results( $sql, ARRAY_A ); - $inflated_events = array(); - $seen_recids = array(); + $inflated_events = []; + $seen_recids = []; if ( ! empty( $events ) ) { $event_count = 0; // if in the frontend we might want to hide rsvp ended events @@ -5360,7 +5360,7 @@ function eme_get_eventids_by_author( $author_id, $scope, $event_id ) { $events_table = $eme_db_prefix . EVENTS_TBNAME; $eme_date_obj_now = new ExpressiveDate( 'now', $eme_timezone ); $this_datetime = $eme_date_obj_now->getDateTime(); - $where_arr = array(); + $where_arr = []; // if an event id is provided, it takes precedence if ( ! empty( $event_id ) ) { @@ -5408,7 +5408,7 @@ function eme_get_event( $event_id ) { } $events_table = $eme_db_prefix . EVENTS_TBNAME; - $conditions = array(); + $conditions = []; if ( is_numeric( $event_id ) ) { $sql = $wpdb->prepare( "SELECT * from $events_table WHERE event_id = %d", $event_id ); @@ -5441,13 +5441,13 @@ function eme_get_event_arr( $event_ids ) { // optimize if only 1 event id if ( count( $event_ids ) == 1 ) { - $events = array(); + $events = []; $events[] = eme_get_event( $event_ids[0] ); return $events; } $events_table = $eme_db_prefix . EVENTS_TBNAME; - $conditions = array(); + $conditions = []; $event_ids_joined = join( ',', $event_ids ); $conditions[] = "event_id IN ($event_ids_joined)"; @@ -5482,10 +5482,10 @@ function eme_get_extra_event_data( $event ) { } $event['event_attributes'] = eme_unserialize( $event['event_attributes'] ); - $event['event_attributes'] = ( ! is_array( $event['event_attributes'] ) ) ? array() : $event['event_attributes']; + $event['event_attributes'] = ( ! is_array( $event['event_attributes'] ) ) ? [] : $event['event_attributes']; $event['event_properties'] = eme_unserialize( $event['event_properties'] ); - $event['event_properties'] = ( ! is_array( $event['event_properties'] ) ) ? array() : $event['event_properties']; + $event['event_properties'] = ( ! is_array( $event['event_properties'] ) ) ? [] : $event['event_properties']; $event['event_properties'] = eme_init_event_props( $event['event_properties'] ); if ( has_filter( 'eme_event_filter' ) ) { @@ -5499,7 +5499,7 @@ function eme_import_csv_events() { $answers_table = $eme_db_prefix . ANSWERS_TBNAME; //validate whether uploaded file is a csv file - $csvMimes = array( 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ); + $csvMimes = [ 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ]; if ( empty( $_FILES['eme_csv']['name'] ) || ! in_array( $_FILES['eme_csv']['type'], $csvMimes ) ) { return sprintf( __( 'No CSV file detected: %s', 'events-made-easy' ), $_FILES['eme_csv']['type'] ); } @@ -5542,7 +5542,7 @@ function eme_import_csv_events() { if ( ! in_array( 'event_name', $headers ) ) { $result = __( 'Not all required fields present.', 'events-made-easy' ); } else { - $empty_props = array(); + $empty_props = []; $empty_props = eme_init_event_props( $empty_props ); // now loop over the rest while ( ( $row = fgetcsv( $handle, 0, $delimiter, $enclosure ) ) !== false ) { @@ -5613,7 +5613,7 @@ function eme_import_csv_events() { if ( preg_match( '/^att_(.*)$/', $key, $matches ) ) { $att = $matches[1]; if ( ! isset( $line['event_attributes'] ) ) { - $line['event_attributes'] = array(); + $line['event_attributes'] = []; } $line['event_attributes'][ $att ] = $value; } @@ -5624,7 +5624,7 @@ function eme_import_csv_events() { if ( preg_match( '/^prop_(.*)$/', $key, $matches ) ) { $prop = $matches[1]; if ( ! isset( $line['event_properties'] ) ) { - $line['event_properties'] = array(); + $line['event_properties'] = []; } if ( array_key_exists( $prop, $empty_props ) ) { $line['event_properties'][ $prop ] = $value; @@ -5695,7 +5695,7 @@ function eme_events_table( $message = '' ) { $hidden_style = ''; } - $scope_names = array(); + $scope_names = []; $scope_names['past'] = __( 'Past events', 'events-made-easy' ); $scope_names['all'] = __( 'All events', 'events-made-easy' ); $scope_names['future'] = __( 'Future events', 'events-made-easy' ); @@ -5855,9 +5855,9 @@ function eme_events_table( $message = '' ) { %2$s »', - $view_button_text, + '%1$s %2$s »', + $view_button_text, /* translators: Accessibility text. */ __( '(opens in a new tab)' ) ); @@ -6377,7 +6377,7 @@ function eme_event_form( $event, $info, $edit_recurrence = 0 ) {

    0 ) { $user_info = get_userdata( $event_author ); if ($user_info !== false) @@ -6397,7 +6397,7 @@ function eme_event_form( $event, $info, $edit_recurrence = 0 ) {

    0 ) { $user_info = get_userdata( $event['event_contactperson_id'] ); @@ -6468,10 +6468,10 @@ function eme_validate_event( $event ) { $event_properties = $event['event_properties']; - $required_fields = array( + $required_fields = [ 'event_name' => __( 'The event name', 'events-made-easy' ), 'start_date' => __( 'The start date', 'events-made-easy' ), - ); + ]; $troubles = ''; if ( eme_is_empty_datetime( $event['event_start'] ) ) { $troubles .= '

  • ' . sprintf( __( '%s is missing!', 'events-made-easy' ), $required_fields['start_date'] ) . '
  • '; @@ -6805,7 +6805,7 @@ function eme_meta_box_div_event_name( $event, $edit_recurrence = 0 ) { $events_prefixes = get_option( 'eme_permalink_events_prefix', 'events' ); if ( preg_match( '/,/', $events_prefixes ) ) { $events_prefixes = explode( ',', $events_prefixes ); - $events_prefixes_arr = array(); + $events_prefixes_arr = []; foreach ( $events_prefixes as $events_prefix ) { $events_prefixes_arr[ $events_prefix ] = eme_permalink_convert( $events_prefix ); } @@ -6909,13 +6909,13 @@ function eme_meta_box_div_event_datetime( $event, $recurrence, $edit_recurrence function eme_meta_box_div_recurrence_info( $recurrence, $edit_recurrence = 0 ) { global $wp_locale; - $freq_options = array( + $freq_options = [ 'daily' => __( 'Daily', 'events-made-easy' ), 'weekly' => __( 'Weekly', 'events-made-easy' ), 'monthly' => __( 'Monthly', 'events-made-easy' ), 'specific' => __( 'Specific days', 'events-made-easy' ), - ); - $days_names = array( + ]; + $days_names = [ 1 => $wp_locale->get_weekday_abbrev( __( 'Monday' ) ), 2 => $wp_locale->get_weekday_abbrev( __( 'Tuesday' ) ), 3 => $wp_locale->get_weekday_abbrev( __( 'Wednesday' ) ), @@ -6923,9 +6923,9 @@ function eme_meta_box_div_recurrence_info( $recurrence, $edit_recurrence = 0 ) { 5 => $wp_locale->get_weekday_abbrev( __( 'Friday' ) ), 6 => $wp_locale->get_weekday_abbrev( __( 'Saturday' ) ), 7 => $wp_locale->get_weekday_abbrev( __( 'Sunday' ) ), - ); + ]; $saved_bydays = explode( ',', $recurrence['recurrence_byday'] ); - $weekno_options = array( + $weekno_options = [ '1' => __( 'first', 'events-made-easy' ), '2' => __( 'second', 'events-made-easy' ), '3' => __( 'third', 'events-made-easy' ), @@ -6933,7 +6933,7 @@ function eme_meta_box_div_recurrence_info( $recurrence, $edit_recurrence = 0 ) { '5' => __( 'fifth', 'events-made-easy' ), '-1' => __( 'last', 'events-made-easy' ), '0' => __( 'Start day', 'events-made-easy' ), - ); + ]; $holidays_array_by_id = eme_get_holidays_array_by_id(); if ( $edit_recurrence && $recurrence['recurrence_freq'] == 'specific' ) { $recurrence_start_date = $recurrence['recurrence_specific_days']; @@ -8207,7 +8207,7 @@ function eme_meta_box_div_event_customfields( $event ) { } elseif ( ! empty( $event['event_id'] ) ) { $answers = eme_get_event_answers( $event['event_id'] ); } else { - $answers = array(); + $answers = []; } foreach ( $formfields as $formfield ) { @@ -8372,7 +8372,7 @@ function eme_meta_box_div_event_rsvp( $event ) { $eme_prop_rsvp_discount = ( $event['event_properties']['rsvp_discount'] ) ? $event['event_properties']['rsvp_discount'] : ''; $eme_prop_rsvp_discountgroup = ( $event['event_properties']['rsvp_discountgroup'] ) ? $event['event_properties']['rsvp_discountgroup'] : ''; - $eme_prop_rsvp_addpersontogroup = ( $event['event_properties']['rsvp_addpersontogroup'] ) ? $event['event_properties']['rsvp_addpersontogroup'] : array(); + $eme_prop_rsvp_addpersontogroup = ( $event['event_properties']['rsvp_addpersontogroup'] ) ? $event['event_properties']['rsvp_addpersontogroup'] : []; $eme_prop_rsvp_password = ( $event['event_properties']['rsvp_password'] ) ? $event['event_properties']['rsvp_password'] : ''; $eme_prop_waitinglist_seats = ( $event['event_properties']['waitinglist_seats'] ) ? $event['event_properties']['waitinglist_seats'] : 0; $eme_prop_cancel_rsvp_days = $event['event_properties']['cancel_rsvp_days']; @@ -8380,14 +8380,14 @@ function eme_meta_box_div_event_rsvp( $event ) { $eme_prop_rsvp_pending_reminder_days = $event['event_properties']['rsvp_pending_reminder_days']; $eme_prop_rsvp_approved_reminder_days = $event['event_properties']['rsvp_approved_reminder_days']; - $discount_arr = array(); - $dgroup_arr = array(); - $group_arr = array(); + $discount_arr = []; + $dgroup_arr = []; + $group_arr = []; if ( ! empty( $eme_prop_rsvp_discount ) ) { - $discount_arr = array( $eme_prop_rsvp_discount => eme_get_discount_name( $eme_prop_rsvp_discount ) ); + $discount_arr = [ $eme_prop_rsvp_discount => eme_get_discount_name( $eme_prop_rsvp_discount ) ]; } if ( ! empty( $eme_prop_rsvp_discountgroup ) ) { - $dgroup_arr = array( $eme_prop_rsvp_discountgroup => eme_get_dgroup_name( $eme_prop_rsvp_discountgroup ) ); + $dgroup_arr = [ $eme_prop_rsvp_discountgroup => eme_get_dgroup_name( $eme_prop_rsvp_discountgroup ) ]; } $pdftemplates = eme_get_templates( 'pdf', 1 ); @@ -8536,18 +8536,18 @@ function eme_meta_box_div_event_rsvp( $event ) {
    '; } } - echo wp_json_encode( array( 'Result' => $form_html ) ); + echo wp_json_encode( [ 'Result' => $form_html ] ); wp_die(); } function eme_dyndata_rsvp_ajax() { header( 'Content-type: application/json; charset=utf-8' ); // first detect multibooking - $event_ids = array(); + $event_ids = []; if ( ! empty( $_POST['eme_event_ids'] ) ) { $event_ids = array_map( 'intval', $_POST['eme_event_ids'] ); } elseif ( eme_is_admin_request() && ! empty( $_POST['event_id'] ) ) { // the case when adding a booking in the backend - $event_ids = array( 0 => intval( $_POST['event_id'] ) ); + $event_ids = [ 0 => intval( $_POST['event_id'] ) ]; } if ( ! empty( $_POST['booking_id'] ) ) { @@ -2197,9 +2197,9 @@ function eme_dyndata_rsvp_ajax() { $booking_id = intval( $_POST['booking_id'] ); check_admin_referer( "eme_admin", 'eme_admin_nonce' ); $booking = eme_get_booking( $booking_id ); - $event_ids = array( 0 => $booking['event_id'] ); + $event_ids = [ 0 => $booking['event_id'] ]; } else { - $booking = array(); + $booking = []; } $form_html = ''; @@ -2321,7 +2321,7 @@ function eme_dyndata_rsvp_ajax() { } } } - echo wp_json_encode( array( 'Result' => do_shortcode( $form_html ) ) ); + echo wp_json_encode( [ 'Result' => do_shortcode( $form_html ) ] ); } function eme_safe_css_attributes( $array ) { @@ -2361,7 +2361,7 @@ function _eme_kses_single( $value, $allow_unfiltered ) { // the first element is the tag, the rest the attributes $tag = array_shift( $info ); if ( ! array_key_exists( $tag, $allowed_html ) ) { - $allowed_html[ $tag ] = array(); + $allowed_html[ $tag ] = []; } foreach ( $info as $attr ) { $allowed_html[ $tag ][ $attr ] = true; @@ -2416,10 +2416,10 @@ function eme_strip_weird( $value ) { # '?', $value); //reject overly long 3 byte sequences and UTF-16 surrogates and replace with ? $value = preg_replace( - '/\xE0[\x80-\x9F][\x80-\xBF]' . + '/\xE0[\x80-\x9F][\x80-\xBF]' . '|\xED[\xA0-\xBF][\x80-\xBF]/S', - '?', - $value + '?', + $value ); return $value; } @@ -2430,12 +2430,12 @@ function eme_get_editor_settings( $tinymce = true, $quicktags = true, $media_but add_action( 'admin_print_footer_scripts', 'eme_add_my_quicktags' ); } - return array( + return [ 'textarea_rows' => $rows, 'tinymce' => $tinymce, 'quicktags' => $quicktags, 'media_buttons' => $media_buttons, - ); + ]; } function eme_nl2br_save_html( $string ) { @@ -2452,7 +2452,7 @@ function eme_nl2br_save_html( $string ) { } // replace other lineendings - $string = str_replace( array( "\r\n", "\r" ), "\n", $string ); + $string = str_replace( [ "\r\n", "\r" ], "\n", $string ); // if br is found, replace it by BREAK $string = preg_replace( "/\n?\n?/", 'BREAK', $string ); @@ -2492,7 +2492,7 @@ function eme_nl2br_save_html( $string ) { function eme_wp_date_format_php_to_datepicker_js( $php_format ) { return $php_format; - $SYMBOLS_MATCHING = array( + $SYMBOLS_MATCHING = [ // Day 'd' => 'dd', 'D' => 'D', @@ -2515,7 +2515,7 @@ function eme_wp_date_format_php_to_datepicker_js( $php_format ) { 'o' => '', 'Y' => 'yyyy', 'y' => 'yy', - ); + ]; $fdatepicker_format = ''; for ( $i = 0; $i < strlen( $php_format ); $i++ ) { $char = $php_format[ $i ]; @@ -2533,7 +2533,7 @@ function eme_wp_date_format_php_to_datepicker_js( $php_format ) { function eme_wp_time_format_php_to_datepicker_js( $php_format ) { return $php_format; - $SYMBOLS_MATCHING = array( + $SYMBOLS_MATCHING = [ 'a' => 'aa', // am/pm 'A' => 'AA', // AM/PM 'g' => 'h', // 12-hour format of an hour without leading zeros @@ -2548,7 +2548,7 @@ function eme_wp_time_format_php_to_datepicker_js( $php_format ) { 'P' => '', // Difference to Greenwich time (GMT) with colon between hours and minutes 'T' => '', // Timezone abbreviation 'Z' => '', // Timezone offset in seconds - ); + ]; $fdatepicker_format = ''; for ( $i = 0; $i < strlen( $php_format ); $i++ ) { $char = $php_format[ $i ]; @@ -2582,14 +2582,14 @@ function eme_getValueFromPath( $arr, $path ) { function eme_get_wp_image( $image_id ) { $image = get_post( $image_id ); - return array( + return [ 'alt' => get_post_meta( $image->ID, '_wp_attachment_image_alt', true ), 'caption' => $image->post_excerpt, 'description' => $image->post_content, 'href' => get_permalink( $image->ID ), 'src' => $image->guid, 'title' => $image->post_title, - ); + ]; } function eme_column_exists( $table_name, $column_name ) { @@ -2775,7 +2775,7 @@ function eme_upload_file_err( $code ) { function eme_upload_files( $id, $type = 'bookings' ) { //$supported_mime_types = wp_get_mime_types(); - $errors = array(); + $errors = []; $max_upload_wp = wp_max_upload_size(); $eme_is_admin_request = eme_is_admin_request(); foreach ( $_FILES as $key => $value ) { @@ -2964,7 +2964,7 @@ function eme_upload_files( $id, $type = 'bookings' ) { } function eme_get_uploaded_files( $id, $type = 'bookings' ) { - $res = array(); + $res = []; $dir = EME_UPLOAD_DIR . '/' . $type . '/' . $id; if ( is_dir( $dir ) ) { if ( $handle = opendir( $dir ) ) { @@ -2976,7 +2976,7 @@ function eme_get_uploaded_files( $id, $type = 'bookings' ) { if ( count( $info ) != 4 ) { continue; } - $line = array(); + $line = []; $line['id'] = $id; $line['type'] = $type; $line['random_id'] = $info[0]; @@ -3027,7 +3027,7 @@ function eme_get_uploaded_file_html( $file ) { } function eme_delTree( $dir ) { - $files = array_diff( scandir( $dir ), array( '.', '..' ) ); + $files = array_diff( scandir( $dir ), [ '.', '..' ] ); foreach ( $files as $file ) { ( is_dir( "$dir/$file" ) ) ? delTree( "$dir/$file" ) : wp_delete_file( "$dir/$file" ); } @@ -3093,15 +3093,15 @@ function eme_fputcsv( $fh, $fields, $delimiter = ';', $enclosure = '"', $mysql_n return; } - $output = array(); + $output = []; foreach ( $fields as $field ) { if ( $field === null && $mysql_null ) { $output[] = 'NULL'; continue; } - $output[] = preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s|\r|\t|\n)/", $field ) ? ( - $enclosure . str_replace( $enclosure, $enclosure . $enclosure, $field ) . $enclosure + $output[] = preg_match( "/(?:{$delimiter_esc}|{$enclosure_esc}|\s|\r|\t|\n)/", $field ) ? ( + $enclosure . str_replace( $enclosure, $enclosure . $enclosure, $field ) . $enclosure ) : $enclosure . $field . $enclosure; } @@ -3117,7 +3117,7 @@ function eme_nocache_headers() { function eme_text_split_newlines( $text ) { // returns an array of trimmed lines, based on text input - $text = str_replace( array( "\r\n", "\r" ), "\n", $text ); + $text = str_replace( [ "\r\n", "\r" ], "\n", $text ); $lines = explode( "\n", $text ); return $lines; } @@ -3125,12 +3125,12 @@ function eme_text_split_newlines( $text ) { function eme_ajax_record_list( $tablename, $cap ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . $tablename; - $jTableResult = array(); + $jTableResult = []; // The toolbar search input $q = isset( $_REQUEST['q'] ) ? eme_sanitize_request($_REQUEST['q']) : ''; $opt = isset( $_REQUEST['opt'] ) ? eme_sanitize_request($_REQUEST['opt']) : ''; $where = ''; - $where_array = array(); + $where_array = []; if ( $q ) { for ( $i = 0; $i < count( $opt ); $i++ ) { $fld = esc_sql( $opt[ $i ] ); @@ -3168,7 +3168,7 @@ function eme_ajax_record_list( $tablename, $cap ) { function eme_ajax_record_delete( $tablename, $cap, $postvar ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . $tablename; - $jTableResult = array(); + $jTableResult = []; if ( current_user_can( get_option( $cap ) ) && isset( $_POST[ $postvar ] ) ) { // check the POST var @@ -3190,7 +3190,7 @@ function eme_ajax_record_delete( $tablename, $cap, $postvar ) { function eme_ajax_record_edit( $tablename, $cap, $id_column, $record, $record_function = '', $update = 0 ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . $tablename; - $jTableResult = array(); + $jTableResult = []; if ( ! $record ) { $jTableResult['Result'] = 'Error'; $jTableResult['Message'] = __( 'No such record', 'events-made-easy' ); @@ -3200,7 +3200,7 @@ function eme_ajax_record_edit( $tablename, $cap, $id_column, $record, $record_fu $wpdb->show_errors( false ); if ( current_user_can( get_option( $cap ) ) ) { if ( $update ) { - $wpdb->update( $table, $record, array( $id_column => $record[ $id_column ] ) ); + $wpdb->update( $table, $record, [ $id_column => $record[ $id_column ] ] ); } else { $wpdb->insert( $table, $record ); } @@ -3235,7 +3235,7 @@ function eme_ajax_record_edit( $tablename, $cap, $id_column, $record, $record_fu function eme_str_split_unicode( $str, $l = 0 ) { if ( $l > 0 ) { - $ret = array(); + $ret = []; $len = mb_strlen( $str, 'UTF-8' ); for ( $i = 0; $i < $len; $i += $l ) { $ret[] = mb_substr( $str, $i, $l, 'UTF-8' ); @@ -3308,7 +3308,7 @@ function eme_create_wp_user( $person ) { if ( has_filter( 'eme_wp_userdata_filter' ) ) { $userdata = apply_filters( 'eme_wp_userdata_filter', $person ); } else { - $userdata = array(); + $userdata = []; } // let's do everything in one go @@ -3343,10 +3343,10 @@ function eme_format_full_name( $firstname, $lastname ) { if ( ! strstr( $format, '#_FIRSTNAME' ) ) { $format .= ' #_FIRSTNAME'; } - $patterns = array(); + $patterns = []; $patterns[0] = '/#_LASTNAME/'; $patterns[1] = '/#_FIRSTNAME/'; - $replacements = array(); + $replacements = []; $replacements[0] = $lastname; $replacements[1] = $firstname; $res = preg_replace( $patterns, $replacements, $format ); @@ -3382,7 +3382,7 @@ function eme_extra_event_headers( $event ) { $header .= "\n"; $header .= ''; - $content = array(); + $content = []; $content['@context'] = 'http://www.schema.org'; $content['@type'] = 'Event'; $content['name'] = '#_EVENTNAME'; @@ -3405,7 +3405,7 @@ function eme_extra_event_headers( $event ) { } // location is a required property, so add it, even if empty - $loc = array(); + $loc = []; $location = eme_get_location( $event['location_id'] ); if ( ! empty( $location ) && ! empty( $location['location_url'] ) ) { if ( $location['location_properties']['online_only'] ) { @@ -3414,13 +3414,13 @@ function eme_extra_event_headers( $event ) { $loc['url'] = '#_LOCATION_EXTERNAL_URL'; } else { $content['eventAttendanceMode'] = 'https://schema.org/MixedEventAttendanceMode'; - $location1 = array(); + $location1 = []; $location1['@type'] = 'VirtualLocation'; $location1['url'] = '#_LOCATION_EXTERNAL_URL'; - $location2 = array(); + $location2 = []; $location2['@type'] = 'Place'; $location2['name'] = '#_LOCATION'; - $address = array(); + $address = []; $address['@type'] = 'PostalAddress'; $address['streetAddress'] = '#_ADDRESS'; $address['addressLocality'] = '#_CITY'; @@ -3434,7 +3434,7 @@ function eme_extra_event_headers( $event ) { $content['eventAttendanceMode'] = 'https://schema.org/OfflineEventAttendanceMode'; $loc['@type'] = 'Place'; $loc['name'] = '#_LOCATION'; - $address = array(); + $address = []; $address['@type'] = 'PostalAddress'; $address['streetAddress'] = '#_ADDRESS'; $address['addressLocality'] = '#_CITY'; @@ -3445,7 +3445,7 @@ function eme_extra_event_headers( $event ) { $content['location'] = $loc; if ( $event['event_rsvp'] ) { - $offers = array(); + $offers = []; $offers['@type'] = 'Offer'; $offers['url'] = '#_EVENTPAGEURL'; if ( ! eme_is_multi( $event['price'] ) ) { @@ -3494,7 +3494,7 @@ function eme_extra_event_headers( $event ) { if ( $answer['field_id'] == $field_id ) { $val = eme_answer2readable( $answer['answer'], $formfield ); if ( ! empty( $val ) ) { - $performer = array(); + $performer = []; $performer['@type'] = 'Person'; $performer['name'] = $val; $content['performer'] = $performer; @@ -3506,12 +3506,12 @@ function eme_extra_event_headers( $event ) { // add something, in case no performer custom field exists if ( ! isset( $content['performer'] ) ) { - $performer = array(); + $performer = []; $performer['@type'] = 'Person'; $performer['name'] = '#_EVENTNAME'; $content['performer'] = $performer; } - $organizer = array(); + $organizer = []; $organizer['@type'] = 'Organization'; $organizer['name'] = '#_CONTACTNAME'; $organizer['url'] = '#_EVENTPAGEURL'; @@ -3540,7 +3540,7 @@ function eme_serialize( $data ) { if ( !eme_is_serialized( $data )) { return json_encode( $data ); } elseif (is_serialized( $data )) { - $data = unserialize( $data, ['allowed_classes' => false] ); + $data = unserialize( $data, ['allowed_classes' => false] ); return json_encode( $data ); } else { return $data; @@ -3552,7 +3552,7 @@ function eme_unserialize( $data ) { return unserialize( $data, ['allowed_classes' => false] ); } elseif (eme_isjson($data)) { // add TRUE to make sure the return is an array - return json_decode ($data,TRUE); + return json_decode ($data, TRUE); } else { return $data; } @@ -3636,7 +3636,7 @@ function eme_generate_qrcode( $url_to_encode, $targetBasePath, $targetBaseUrl, $ $target_file = $targetBasePath . '/' . basename( $existing_file ); $target_url = $targetBaseUrl . '/' . basename( $existing_file ); } - return array( $target_file, $target_url ); + return [ $target_file, $target_url ]; } function eme_check_access( $post_id ) { @@ -3653,12 +3653,12 @@ function eme_check_access( $post_id ) { if ( eme_is_serialized( $eme_membershipids ) ) { $page_membershipids = eme_unserialize( $eme_membershipids ); } else { - $page_membershipids = array(); + $page_membershipids = []; } if ( eme_is_serialized( $eme_groupids ) ) { $page_groupids = eme_unserialize( $eme_groupids ); } else { - $page_groupids = array(); + $page_groupids = []; } if ( ! empty( $page_membershipids ) ) { // check if the memberships still exist @@ -3722,7 +3722,7 @@ function eme_migrate_event_payment_options() { global $wpdb,$eme_db_prefix; $table_name = $eme_db_prefix . EVENTS_TBNAME; - $payment_options = array( 'use_paypal', 'use_2co', 'use_webmoney', 'use_fdgg', 'use_mollie' ); + $payment_options = [ 'use_paypal', 'use_2co', 'use_webmoney', 'use_fdgg', 'use_mollie' ]; foreach ( $payment_options as $payment_option ) { $sql = "SELECT event_id from $table_name WHERE $payment_option=1"; $ids = $wpdb->get_col( $sql ); @@ -3839,12 +3839,12 @@ function eme_is_datamaster() { function eme_get_initials( $myname ) { $words = preg_split( '/\s/', $myname, -1, PREG_SPLIT_NO_EMPTY ); $res = implode( - '.', - array_map( - function ( $a ) { + '.', + array_map( + function ( $a ) { return mb_substr( $a[0], 0, 1, 'UTF-8' ); }, - $words + $words ) ); // add trailing '.' diff --git a/eme-gdpr.php b/eme-gdpr.php index b14e1e50..1f62362d 100644 --- a/eme-gdpr.php +++ b/eme-gdpr.php @@ -12,14 +12,14 @@ function eme_gdpr_approve_url( $email ) { $the_link = remove_query_arg( 'lang', $the_link ); $nonce = wp_create_nonce( "gdpr $email" ); $the_link = add_query_arg( - array( + [ 'eme_gdpr_approve' => $email, 'eme_gdpr_nonce' => $nonce, - ), - $the_link + ], + $the_link ); if ( ! empty( $language ) ) { - $the_link = add_query_arg( array( 'lang' => $language ), $the_link ); + $the_link = add_query_arg( [ 'lang' => $language ], $the_link ); } return $the_link; } @@ -32,14 +32,14 @@ function eme_gdpr_url( $email ) { $the_link = remove_query_arg( 'lang', $the_link ); $nonce = wp_create_nonce( "gdpr $email" ); $the_link = add_query_arg( - array( + [ 'eme_gdpr' => $email, 'eme_gdpr_nonce' => $nonce, - ), - $the_link + ], + $the_link ); if ( ! empty( $language ) ) { - $the_link = add_query_arg( array( 'lang' => $language ), $the_link ); + $the_link = add_query_arg( [ 'lang' => $language ], $the_link ); } return $the_link; } @@ -52,10 +52,10 @@ function eme_gdpr_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $form_html = __( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -63,10 +63,10 @@ function eme_gdpr_ajax() { if ( ! isset( $_POST['eme_frontend_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) { $form_html = __( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -92,10 +92,10 @@ function eme_gdpr_ajax() { } $form_html = __( 'Thank you for your request, an email will be sent with further info', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -109,7 +109,7 @@ function eme_rpi_shortcode( $atts ) { $email = ''; } - $atts = shortcode_atts( array( 'show_info_if_logged_in' => 0 ), $atts ); + $atts = shortcode_atts( [ 'show_info_if_logged_in' => 0 ], $atts ); $show_info_if_logged_in = filter_var( $atts['show_info_if_logged_in'], FILTER_VALIDATE_BOOLEAN ); // for logged in users that are linked to an EME user, immediately show the info @@ -143,10 +143,10 @@ function eme_gdpr_approve_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $form_html = __( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -154,10 +154,10 @@ function eme_gdpr_approve_ajax() { if ( ! isset( $_POST['eme_frontend_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) { $form_html = __( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -183,10 +183,10 @@ function eme_gdpr_approve_ajax() { } $form_html = __( 'Thank you for your request, an email will be sent with further info', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -221,10 +221,10 @@ function eme_cpi_request_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $message = __( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -232,10 +232,10 @@ function eme_cpi_request_ajax() { if ( ! isset( $_POST['eme_frontend_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) { $message = __( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -294,10 +294,10 @@ function eme_cpi_request_ajax() { } $message = __( 'Thank you for your request, an email will be sent with further info.', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -311,7 +311,7 @@ function eme_cpi_shortcode( $atts ) { $email = ''; } - $atts = shortcode_atts( array( 'show_form_if_logged_in' => 0 ), $atts ); + $atts = shortcode_atts( [ 'show_form_if_logged_in' => 0 ], $atts ); $show_form_if_logged_in = filter_var( $atts['show_form_if_logged_in'], FILTER_VALIDATE_BOOLEAN ); // for logged in users that are linked to an EME user, immediately show the form @@ -345,10 +345,10 @@ function eme_cpi_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $message = __( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -356,10 +356,10 @@ function eme_cpi_ajax() { if ( empty( $_POST['person_id'] ) ) { $message = __( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -367,10 +367,10 @@ function eme_cpi_ajax() { if ( ! isset( $_POST['eme_cpi_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_cpi_nonce']), "eme_cpi $person_id" ) ) { $message = __( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -378,10 +378,10 @@ function eme_cpi_ajax() { if ( ! eme_check_recaptcha() ) { $message = __( 'Please check the Google reCAPTCHA box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -389,10 +389,10 @@ function eme_cpi_ajax() { if ( ! eme_check_hcaptcha() ) { $message = __( 'Please check the hCaptcha box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -400,15 +400,15 @@ function eme_cpi_ajax() { if ( ! eme_check_captcha( 1 ) ) { $message = __( 'You entered an incorrect code', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } } - list($person_id,$add_update_message) = eme_add_update_person_from_form( $person_id ); + [$person_id, $add_update_message] = eme_add_update_person_from_form( $person_id ); if ( $person_id ) { $message = __( 'Person updated', 'events-made-easy' ); } else { @@ -416,10 +416,10 @@ function eme_cpi_ajax() { $message .= '
    ' . $add_update_message; } echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -483,7 +483,7 @@ function eme_show_personal_info( $email ) { $output .= '' . __( 'MassMail', 'events-made-easy' ) . '' . $massmail . ''; $output .= '' . __( 'GDPR approval', 'events-made-easy' ) . '' . $gdpr . ''; if ( ! empty( $person['properties']['image_id'] ) ) { - $img = wp_get_attachment_image( $person['properties']['image_id'], 'full', 0, array( 'class' => 'eme_person_image' ) ); + $img = wp_get_attachment_image( $person['properties']['image_id'], 'full', 0, [ 'class' => 'eme_person_image' ] ); $output .= '' . __( 'Image', 'events-made-easy' ) . '' . $img . ''; } $output .= '' . __( 'Member of group(s)', 'events-made-easy' ) . '' . eme_esc_html( $groups ) . ''; @@ -569,14 +569,14 @@ function eme_gdpr_add_suggested_privacy_content() { } function eme_gdpr_register_exporters( $exporters ) { - $exporters[] = array( + $exporters[] = [ 'exporter_friendly_name' => __( 'Events Made Easy' ), 'callback' => 'eme_gdpr_user_data_exporter', - ); + ]; return $exporters; } function eme_gdpr_user_data_exporter( $email, $page = 1 ) { - $export_items = array(); + $export_items = []; if ( eme_count_persons_by_email( $email ) > 0 ) { $person_ids = eme_get_personids_by_email( $email ); $eme_address1_string = get_option( 'eme_address1_string' ); @@ -588,133 +588,133 @@ function eme_gdpr_user_data_exporter( $email, $page = 1 ) { $groups = join( ',', eme_get_persongroup_names( $person['person_id'] ) ); $massmail = $person['massmail'] ? __( 'Yes', 'events-made-easy' ) : __( 'No', 'events-made-easy' ); $gdpr = $person['gdpr'] ? __( 'Yes', 'events-made-easy' ) : __( 'No', 'events-made-easy' ); - $data = array(); - $data[] = array( + $data = []; + $data[] = [ 'name' => __( 'Person ID', 'events-made-easy' ), 'value' => $person['person_id'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'Last name', 'events-made-easy' ), 'value' => $person['lastname'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'First name', 'events-made-easy' ), 'value' => $person['firstname'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'Email', 'events-made-easy' ), 'value' => $person['email'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => $eme_address1_string, 'value' => $person['address1'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => $eme_address1_string, 'value' => $person['address2'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'City', 'events-made-easy' ), 'value' => $person['city'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'Postal code', 'events-made-easy' ), 'value' => $person['zip'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'State', 'events-made-easy' ), 'value' => eme_get_state_name( $person['state_code'], $person['country_code'], $person['lang'] ), - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'Country', 'events-made-easy' ), 'value' => eme_get_country_name( $person['country_code'], $person['lang'] ), - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'Phone number', 'events-made-easy' ), 'value' => $person['phone'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'MassMail', 'events-made-easy' ), 'value' => $massmail, - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'GDPR approval', 'events-made-easy' ), 'value' => $gdpr, - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'Member of group(s)', 'events-made-easy' ), 'value' => $groups, - ); + ]; foreach ( $answers as $answer ) { $formfield = eme_get_formfield( $answer['field_id'] ); if ( ! empty( $formfield ) ) { - $data[] = array( + $data[] = [ 'name' => eme_translate( $formfield['field_name'] ), 'value' => eme_answer2readable( $answer['answer'], $formfield, 1, ',', 'text' ), - ); + ]; } } // Add this group of items to the exporters data array. $group_id = 'eme-personal-data'; $group_label = __( 'Events Made Easy Personal Data', 'event-made-easy' ); - $export_items[] = array( + $export_items[] = [ 'group_id' => $group_id, 'group_label' => $group_label, 'item_id' => $person_id, 'data' => $data, - ); + ]; // Now the media $files = eme_get_uploaded_files( $person_id, 'people' ); if ( ! empty( $files ) ) { $group_id = 'eme-personal-data-media'; $group_label = __( 'Events Made Easy Uploaded files linked to the person', 'event-made-easy' ); - $data = array(); + $data = []; foreach ( $files as $file ) { - $data[] = array( + $data[] = [ 'name' => eme_translate( $file['field_name'] ), 'value' => "" . $file['name'] . '', - ); + ]; } - $export_items[] = array( + $export_items[] = [ 'group_id' => $group_id, 'group_label' => $group_label, 'item_id' => $person_id, 'data' => $data, - ); + ]; } if ( count( $members ) > 0 ) { foreach ( $members as $member ) { $start_date = eme_localized_date( $member['start_date'] ); $end_date = eme_localized_date( $member['end_date'] ); - $data = array(); - $data[] = array( + $data = []; + $data[] = [ 'name' => __( 'Member ID', 'events-made-easy' ), 'value' => $member['member_id'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'Membership', 'events-made-easy' ), 'value' => $member['membership_name'], - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'Start', 'events-made-easy' ), 'value' => $start_date, - ); - $data[] = array( + ]; + $data[] = [ 'name' => __( 'End', 'events-made-easy' ), 'value' => $end_date, - ); + ]; $related_member_ids = eme_get_family_member_ids( $member['member_id'] ); if ( ! empty( $related_member_ids ) ) { $related_member = eme_get_member( $related_member_id ); if ( $related_member ) { $related_person = eme_get_person( $related_member['person_id'] ); if ( $related_person ) { - $data[] = array( + $data[] = [ 'name' => __( 'Main family account for', 'events-made-easy' ), 'value' => eme_format_full_name( $related_person['firstname'], $related_person['lastname'] ) . ' (' . $related_person['email'] . ')', - ); + ]; } } } @@ -722,38 +722,38 @@ function eme_gdpr_user_data_exporter( $email, $page = 1 ) { foreach ( $answers as $answer ) { $formfield = eme_get_formfield( $answer['field_id'] ); if ( ! empty( $formfield ) ) { - $data[] = array( + $data[] = [ 'name' => eme_translate( $formfield['field_name'] ), 'value' => eme_answer2readable( $answer['answer'], $formfield, 1, ',', 'text' ), - ); + ]; } } $group_id = 'eme-member-data'; $group_label = __( 'Events Made Easy Member Data', 'event-made-easy' ); - $export_items[] = array( + $export_items[] = [ 'group_id' => $group_id, 'group_label' => $group_label, 'item_id' => $member['member_id'], 'data' => $data, - ); + ]; // Now the media $files = eme_get_uploaded_files( $member['member_id'], 'members' ); if ( ! empty( $files ) ) { $group_id = 'eme-member-data-media'; $group_label = __( 'Events Made Easy Uploaded files linked to the member', 'event-made-easy' ); - $data = array(); + $data = []; foreach ( $files as $file ) { - $data[] = array( + $data[] = [ 'name' => eme_translate( $file['field_name'] ), 'value' => "" . $file['name'] . '', - ); + ]; } - $export_items[] = array( + $export_items[] = [ 'group_id' => $group_id, 'group_label' => $group_label, 'item_id' => $person_id, 'data' => $data, - ); + ]; } } } @@ -761,27 +761,27 @@ function eme_gdpr_user_data_exporter( $email, $page = 1 ) { } // Returns an array of exported items for this pass, but also a boolean whether this exporter is finished. //If not it will be called again with $page increased by 1. - return array( + return [ 'data' => $export_items, 'done' => true, - ); + ]; } -function eme_gdpr_register_erasers( $erasers = array() ) { - $erasers[] = array( +function eme_gdpr_register_erasers( $erasers = [] ) { + $erasers[] = [ 'eraser_friendly_name' => __( 'Events Made Easy' ), 'callback' => 'eme_gdpr_user_data_eraser', - ); + ]; return $erasers; } function eme_gdpr_user_data_eraser( $email, $page = 1 ) { if ( empty( $email ) ) { - return array( + return [ 'items_removed' => false, 'items_retained' => false, - 'messages' => array(), + 'messages' => [], 'done' => true, - ); + ]; } $person_ids = eme_get_personids_by_email( $email ); if ( ! empty( $person_ids ) ) { @@ -790,14 +790,14 @@ function eme_gdpr_user_data_eraser( $email, $page = 1 ) { } $items_removed = true; $items_retained = false; - $messages = array(); + $messages = []; $messages[] = __( "All data from the plugin Events Made Easy related to this email has been removed, but don't forget this also cancelled the corresponding memberships!", 'events-made-easy' ); - return array( + return [ 'items_removed' => $items_removed, 'items_retained' => $items_retained, 'messages' => $messages, 'done' => true, - ); + ]; } diff --git a/eme-holidays.php b/eme-holidays.php index ac4f2a6c..68b608a1 100644 --- a/eme-holidays.php +++ b/eme-holidays.php @@ -5,10 +5,10 @@ } function eme_new_holidays() { - $hol = array( + $hol = [ 'name' => '', 'list' => '', - ); + ]; return $hol; } @@ -41,11 +41,11 @@ function eme_holidays_page() { check_admin_referer( 'eme_admin', 'eme_admin_nonce' ); if ( $_POST['eme_admin_action'] == 'do_editholidays' ) { // holidays update required - $holidays = array(); + $holidays = []; $holidays['name'] = eme_sanitize_request( $_POST['name'] ); $holidays['list'] = eme_sanitize_textarea( $_POST['list'] ); if ( ! empty( $_POST['id'] ) ) { - $validation_result = $wpdb->update( $holidays_table, $holidays, array( 'id' => intval( $_POST['id'] ) ) ); + $validation_result = $wpdb->update( $holidays_table, $holidays, [ 'id' => intval( $_POST['id'] ) ] ); if ( $validation_result !== false ) { $message = __( 'Successfully edited the list of holidays', 'events-made-easy' ); } else { @@ -241,11 +241,11 @@ function eme_get_holiday_list( $id ) { function eme_get_holiday_listinfo( $id ) { $holiday_list = eme_get_holiday_list( $id ); - $res_days = array(); + $res_days = []; $days = explode( "\n", str_replace( "\r", "\n", $holiday_list['list'] ) ); foreach ( $days as $day_info ) { //$info=explode(',',$day_info); - list($date_info,$name,$class,$link) = array_pad( explode( ',', $day_info ), 4, '' ); + [$date_info, $name, $class, $link] = array_pad( explode( ',', $day_info ), 4, '' ); if ( preg_match( '/^([0-9]{4}-[0-9]{2}-[0-9]{2})--([0-9]{4}-[0-9]{2}-[0-9]{2})$/', $date_info, $matches ) ) { $start = $matches[1]; $end = $matches[2]; @@ -269,7 +269,7 @@ function eme_get_holiday_listinfo( $id ) { function eme_get_holidays_array_by_id() { $holidays = eme_get_holiday_lists(); - $holidays_by_id = array(); + $holidays_by_id = []; if ( ! empty( $holidays ) ) { $holidays_by_id[] = ''; foreach ( $holidays as $holiday_list ) { @@ -284,12 +284,12 @@ function eme_holidays_shortcode( $atts ) { global $eme_timezone; eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => '', 'scope' => 'all', - ), - $atts + ], + $atts ) ); @@ -304,7 +304,7 @@ function eme_holidays_shortcode( $atts ) { $eme_date_obj_now = new ExpressiveDate( 'now', $eme_timezone ); print '
    '; foreach ( $days as $day_info ) { - list($day,$name,$class) = array_pad( explode( ',', $day_info ), 3, '' ); + [$day, $name, $class] = array_pad( explode( ',', $day_info ), 3, '' ); if ( empty( $day ) ) { continue; } diff --git a/eme-ical.php b/eme-ical.php index 8e557fc1..0ae4e20a 100644 --- a/eme-ical.php +++ b/eme-ical.php @@ -120,7 +120,7 @@ function eme_ical_link( $justurl = 0, $echo = 0, $text = 'ICAL', $category = '', if ( strpos( $justurl, '=' ) ) { // allows the use of arguments without breaking the legacy code - $defaults = array( + $defaults = [ 'justurl' => 0, 'echo' => $echo, 'text' => $text, @@ -130,7 +130,7 @@ function eme_ical_link( $justurl = 0, $echo = 0, $text = 'ICAL', $category = '', 'contact_person' => $contact_person, 'location_id' => $location_id, 'notcategory' => $notcategory, - ); + ]; $r = wp_parse_args( $justurl, $defaults ); extract( $r ); @@ -143,25 +143,25 @@ function eme_ical_link( $justurl = 0, $echo = 0, $text = 'ICAL', $category = '', } $url = site_url( '/?eme_ical=public' ); if ( ! empty( $location_id ) ) { - $url = add_query_arg( array( 'location_id' => $location_id ), $url ); + $url = add_query_arg( [ 'location_id' => $location_id ], $url ); } if ( ! empty( $category ) ) { - $url = add_query_arg( array( 'category' => $category ), $url ); + $url = add_query_arg( [ 'category' => $category ], $url ); } if ( ! empty( $notcategory ) ) { - $url = add_query_arg( array( 'notcategory' => $notcategory ), $url ); + $url = add_query_arg( [ 'notcategory' => $notcategory ], $url ); } if ( ! empty( $scope ) ) { - $url = add_query_arg( array( 'scope' => $scope ), $url ); + $url = add_query_arg( [ 'scope' => $scope ], $url ); } if ( ! empty( $author ) ) { - $url = add_query_arg( array( 'author' => $author ), $url ); + $url = add_query_arg( [ 'author' => $author ], $url ); } if ( ! empty( $contact_person ) ) { - $url = add_query_arg( array( 'contact_person' => $contact_person ), $url ); + $url = add_query_arg( [ 'contact_person' => $contact_person ], $url ); } if ( ! empty( $language ) ) { - $url = add_query_arg( array( 'lang' => $language ), $url ); + $url = add_query_arg( [ 'lang' => $language ], $url ); } $link = "$text"; @@ -180,8 +180,8 @@ function eme_ical_link( $justurl = 0, $echo = 0, $text = 'ICAL', $category = '', function eme_ical_link_shortcode( $atts ) { extract( - shortcode_atts( - array( + shortcode_atts( + [ 'justurl' => 0, 'text' => 'ICAL', 'category' => '', @@ -190,8 +190,8 @@ function eme_ical_link_shortcode( $atts ) { 'author' => '', 'contact_person' => '', 'notcategory' => '', - ), - $atts + ], + $atts ) ); diff --git a/eme-locations.php b/eme-locations.php index c650f3f1..1d58cb2a 100644 --- a/eme-locations.php +++ b/eme-locations.php @@ -5,7 +5,7 @@ } function eme_new_location() { - $location = array( + $location = [ 'location_name' => '', 'location_address1' => '', 'location_address2' => '', @@ -24,14 +24,14 @@ function eme_new_location() { 'location_external_ref' => '', 'location_image_id' => 0, 'location_author' => 0, - 'location_attributes' => array(), - ); + 'location_attributes' => [], + ]; $location['location_properties'] = eme_init_location_props(); return $location; } -function eme_init_location_props( $props = array() ) { +function eme_init_location_props( $props = [] ) { if ( ! isset( $props['map_icon'] ) ) { $props['map_icon'] = ''; } @@ -112,7 +112,7 @@ function eme_locations_page() { $message = __( 'You have no right to edit this location!', 'events-made-easy' ); eme_locations_table( $message ); } else { - $post_vars = array( 'location_name', 'location_address1', 'location_address2', 'location_city', 'location_state', 'location_zip', 'location_country', 'location_url', 'location_image_url', 'location_image_id', 'location_prefix', 'location_slug', 'location_latitude', 'location_longitude', 'location_author' ); + $post_vars = [ 'location_name', 'location_address1', 'location_address2', 'location_city', 'location_state', 'location_zip', 'location_country', 'location_url', 'location_image_url', 'location_image_id', 'location_prefix', 'location_slug', 'location_latitude', 'location_longitude', 'location_author' ]; foreach ( $post_vars as $post_var ) { if ( isset( $_POST[ $post_var ] ) ) { $location[ $post_var ] = eme_sanitize_request( $_POST[ $post_var ] ); @@ -127,7 +127,7 @@ function eme_locations_page() { $location ['location_category_ids'] = ''; } - $location_attributes = array(); + $location_attributes = []; for ( $i = 1; isset( $_POST[ "eme_attr_{$i}_ref" ] ) && trim( $_POST[ "eme_attr_{$i}_ref" ] ) != ''; $i++ ) { if ( trim( $_POST[ "eme_attr_{$i}_name" ] ) != '' ) { $location_attributes[ $_POST[ "eme_attr_{$i}_ref" ] ] = eme_kses( $_POST[ "eme_attr_{$i}_name" ] ); @@ -135,10 +135,10 @@ function eme_locations_page() { } $location['location_attributes'] = $location_attributes; - $location_properties = array(); + $location_properties = []; $location_properties = eme_init_location_props( $location_properties ); // now for the select boxes, we need to set to 0 if not in the _POST - $select_location_post_vars = array( 'online_only' ); + $select_location_post_vars = [ 'online_only' ]; foreach ( $select_location_post_vars as $post_var ) { if ( ! isset( $_POST[ 'eme_loc_prop_' . $post_var ] ) ) { $location_properties[ $post_var ] = 0; @@ -201,7 +201,7 @@ function eme_import_csv_locations() { $answers_table = $eme_db_prefix . ANSWERS_TBNAME; //validate whether uploaded file is a csv file - $csvMimes = array( 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ); + $csvMimes = [ 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ]; if ( empty( $_FILES['eme_csv']['name'] ) || ! in_array( $_FILES['eme_csv']['type'], $csvMimes ) ) { return sprintf( __( 'No CSV file detected: %s', 'events-made-easy' ), $_FILES['eme_csv']['type'] ); } @@ -244,7 +244,7 @@ function eme_import_csv_locations() { if ( ! in_array( 'location_name', $headers ) || ! in_array( 'location_address1', $headers ) ) { $result = __( 'Not all required fields present.', 'events-made-easy' ); } else { - $empty_props = array(); + $empty_props = []; $empty_props = eme_init_location_props( $empty_props ); // now loop over the rest while ( ( $row = fgetcsv( $handle, 0, $delimiter, $enclosure ) ) !== false ) { @@ -258,7 +258,7 @@ function eme_import_csv_locations() { if ( preg_match( '/^att_(.*)$/', $key, $matches ) ) { $att = $matches[1]; if ( ! isset( $line['location_attributes'] ) ) { - $line['location_attributes'] = array(); + $line['location_attributes'] = []; } $line['location_attributes'][ $att ] = $value; } @@ -269,7 +269,7 @@ function eme_import_csv_locations() { if ( preg_match( '/^prop_(.*)$/', $key, $matches ) ) { $prop = $matches[1]; if ( ! isset( $line['location_properties'] ) ) { - $line['location_properties'] = array(); + $line['location_properties'] = []; } if ( array_key_exists( $prop, $empty_props ) ) { $line['location_properties'][ $prop ] = $value; @@ -435,11 +435,11 @@ function eme_locations_edit_layout( $location, $message = '' ) {

    'location_author', 'selected' => $location_author, - ) - ); + ] + ); ?>

    @@ -505,7 +505,7 @@ function eme_meta_box_div_location_name( $location ) { $locations_prefixes = get_option( 'eme_permalink_locations_prefix', 'locations' ); if ( preg_match( '/,/', $locations_prefixes ) ) { $locations_prefixes = explode( ',', $locations_prefixes ); - $locations_prefixes_arr = array(); + $locations_prefixes_arr = []; foreach ( $locations_prefixes as $locations_prefix ) { $locations_prefixes_arr[ $locations_prefix ] = eme_permalink_convert( $locations_prefix ); } @@ -765,7 +765,7 @@ function eme_meta_box_div_location_customfields( $location ) { } elseif ( ! empty( $location['location_id'] ) ) { $answers = eme_get_location_answers( $location['location_id'] ); } else { - $answers = array(); + $answers = []; } foreach ( $formfields as $formfield ) { @@ -889,9 +889,9 @@ function eme_locations_table( $message = '' ) { 0 ) { @@ -1070,7 +1070,7 @@ function eme_get_locations( $eventful = false, $scope = 'all', $category = '', $ $conditions [] = "location_category_ids=''"; } elseif ( preg_match( '/,/', $category ) ) { $category = explode( ',', $category ); - $category_conditions = array(); + $category_conditions = []; foreach ( $category as $cat ) { if ( is_numeric( $cat ) && $cat > 0 ) { $category_conditions[] = " FIND_IN_SET($cat,location_category_ids)"; @@ -1081,7 +1081,7 @@ function eme_get_locations( $eventful = false, $scope = 'all', $category = '', $ $conditions [] = '(' . implode( ' OR', $category_conditions ) . ')'; } elseif ( preg_match( '/\+/', $category ) ) { $category = explode( '+', $category ); - $category_conditions = array(); + $category_conditions = []; foreach ( $category as $cat ) { if ( is_numeric( $cat ) && $cat > 0 ) { $category_conditions[] = " FIND_IN_SET($cat,location_category_ids)"; @@ -1098,7 +1098,7 @@ function eme_get_locations( $eventful = false, $scope = 'all', $category = '', $ $conditions[] = "location_category_ids != ''"; } elseif ( preg_match( '/,/', $notcategory ) ) { $notcategory = explode( ',', $notcategory ); - $category_conditions = array(); + $category_conditions = []; foreach ( $notcategory as $cat ) { if ( is_numeric( $cat ) && $cat > 0 ) { $category_conditions[] = "(NOT FIND_IN_SET($cat,location_category_ids) OR location_category_ids IS NULL)"; @@ -1110,7 +1110,7 @@ function eme_get_locations( $eventful = false, $scope = 'all', $category = '', $ } elseif ( preg_match( '/\+| /', $notcategory ) ) { // url decoding of '+' is ' ' $notcategory = preg_split( '/\+| /', $notcategory, 0, PREG_SPLIT_NO_EMPTY ); - $category_conditions = array(); + $category_conditions = []; foreach ( $notcategory as $cat ) { if ( is_numeric( $cat ) && $cat > 0 ) { $category_conditions[] = "(NOT FIND_IN_SET($cat,location_category_ids) OR location_category_ids IS NULL)"; @@ -1216,10 +1216,10 @@ function eme_get_extra_location_data( $location ) { } } $location['location_attributes'] = eme_unserialize( $location['location_attributes'] ); - $location['location_attributes'] = ( ! is_array( $location['location_attributes'] ) ) ? array() : $location['location_attributes']; + $location['location_attributes'] = ( ! is_array( $location['location_attributes'] ) ) ? [] : $location['location_attributes']; $location['location_properties'] = eme_unserialize( $location['location_properties'] ); - $location['location_properties'] = ( ! is_array( $location['location_properties'] ) ) ? array() : $location['location_properties']; + $location['location_properties'] = ( ! is_array( $location['location_properties'] ) ) ? [] : $location['location_properties']; $location['location_properties'] = eme_init_location_props( $location['location_properties'] ); if ( has_filter( 'eme_location_filter' ) ) { @@ -1232,10 +1232,10 @@ function eme_get_extra_location_data( $location ) { function eme_get_city_location_ids( $cities ) { global $wpdb,$eme_db_prefix; $locations_table = $eme_db_prefix . LOCATIONS_TBNAME; - $location_ids = array(); + $location_ids = []; $conditions = ''; if ( is_array( $cities ) ) { - $city_conditions = array(); + $city_conditions = []; foreach ( $cities as $city ) { $city_conditions[] = " location_city = '" . esc_sql( $city ) . "'"; } @@ -1253,10 +1253,10 @@ function eme_get_city_location_ids( $cities ) { function eme_get_country_location_ids( $countries ) { global $wpdb,$eme_db_prefix; $locations_table = $eme_db_prefix . LOCATIONS_TBNAME; - $location_ids = array(); + $location_ids = []; $conditions = ''; if ( is_array( $countries ) ) { - $country_conditions = array(); + $country_conditions = []; foreach ( $countries as $country ) { $country_conditions[] = " location_country = '" . esc_sql( $country ) . "'"; } @@ -1285,7 +1285,7 @@ function eme_sanitize_location( $location ) { } // check all variables that need to be urls - $url_vars = array( 'location_url', 'location_image_url' ); + $url_vars = [ 'location_url', 'location_image_url' ]; foreach ( $url_vars as $url_var ) { if ( ! empty( $location[ $url_var ] ) ) { //make sure url's have a correct prefix @@ -1313,7 +1313,7 @@ function eme_sanitize_location( $location ) { } // some things just need to be integers, let's brute-force them - $int_vars = array( 'location_image_id', 'location_author' ); + $int_vars = [ 'location_image_id', 'location_author' ]; foreach ( $int_vars as $int_var ) { if ( isset( $location[ $int_var ] ) ) { $location[ $int_var ] = intval( $location[ $int_var ] ); @@ -1324,11 +1324,11 @@ function eme_sanitize_location( $location ) { } function eme_validate_location( $location ) { - $location_required_fields = array( + $location_required_fields = [ 'location_name' => __( 'The location name', 'events-made-easy' ), 'location_address1' => __( 'The location address', 'events-made-easy' ), 'location_city' => __( 'The location city', 'events-made-easy' ), - ); + ]; $troubles = ''; if ( empty( $location['location_name'] ) ) { $troubles .= '
  • ' . sprintf( __( '%s is missing!', 'events-made-easy' ), $location_required_fields['location_name'] ) . '
  • '; @@ -1371,7 +1371,7 @@ function eme_update_location( $line, $location_id ) { $new_line['location_properties'] = eme_serialize( $new_line['location_properties'] ); $wpdb->show_errors( true ); - $where = array( 'location_id' => $location_id ); + $where = [ 'location_id' => $location_id ]; if ( $wpdb->update( $table_name, $new_line, $where ) === false ) { $wpdb->print_error(); $wpdb->show_errors( false ); @@ -1514,8 +1514,8 @@ function eme_global_map_shortcode( $atts ) { // the locations shortcode has been deteced, so we indicate // that we want the javascript in the footer as well extract( - shortcode_atts( - array( + shortcode_atts( + [ 'show_locations' => true, 'letter_icons' => true, 'show_events' => false, @@ -1531,8 +1531,8 @@ function eme_global_map_shortcode( $atts ) { 'width' => 450, 'height' => 300, 'list_location' => 'after', - ), - $atts + ], + $atts ) ); $eventful = filter_var( $eventful, FILTER_VALIDATE_BOOLEAN ); @@ -1659,10 +1659,10 @@ function eme_global_map_shortcode( $atts ) { // remove the offset info $this_page_url = remove_query_arg( 'eme_offset', $this_page_url ); if ( $prev_text != '' ) { - $pagination_top .= " $prev_offset ), $this_page_url ) . "'><< $prev_text"; + $pagination_top .= " $prev_offset ], $this_page_url ) . "'><< $prev_text"; } if ( $next_text != '' ) { - $pagination_top .= " $next_offset ), $this_page_url ) . "'>$next_text >>"; + $pagination_top .= " $next_offset ], $this_page_url ) . "'>$next_text >>"; } $pagination_top .= "$scope_text"; $pagination_top .= '
    '; @@ -1722,14 +1722,14 @@ function eme_global_map_shortcode( $atts ) { function eme_single_location_map_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => '', 'width' => 0, 'height' => 0, 'zoom' => get_option( 'eme_indiv_zoom_factor' ), - ), - $atts + ], + $atts ) ); $location = eme_get_location( $id ); @@ -1764,13 +1764,13 @@ function eme_display_single_location( $location_id, $template_id = 0, $ignore_ur function eme_get_location_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => '', 'template_id' => 0, 'ignore_url' => 0, - ), - $atts + ], + $atts ) ); $ignore_url = filter_var( $ignore_url, FILTER_VALIDATE_BOOLEAN ); @@ -1780,8 +1780,8 @@ function eme_get_location_shortcode( $atts ) { function eme_get_locations_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'eventful' => false, 'ignore_filter' => false, 'random_order' => false, @@ -1794,8 +1794,8 @@ function eme_get_locations_shortcode( $atts ) { 'template_id' => 0, 'template_id_header' => 0, 'template_id_footer' => 0, - ), - $atts + ], + $atts ) ); $eventful = filter_var( $eventful, FILTER_VALIDATE_BOOLEAN ); @@ -2105,7 +2105,7 @@ function eme_replace_locations_placeholders( $format, $location = '', $target = } } elseif ( preg_match( '/#_LOCATIONIMAGE$/', $result ) ) { if ( ! empty( $location['location_image_id'] ) ) { - $replacement = wp_get_attachment_image( $location['location_image_id'], 'full', 0, array( 'class' => 'eme_location_image' ) ); + $replacement = wp_get_attachment_image( $location['location_image_id'], 'full', 0, [ 'class' => 'eme_location_image' ] ); } elseif ( ! empty( $location['location_image_url'] ) ) { $url = $location['location_image_url']; if ( $target == 'html' ) { @@ -2133,7 +2133,7 @@ function eme_replace_locations_placeholders( $format, $location = '', $target = } } elseif ( preg_match( '/#_LOCATIONIMAGETHUMB$/', $result ) ) { if ( ! empty( $location['location_image_id'] ) ) { - $replacement = wp_get_attachment_image( $location['location_image_id'], get_option( 'eme_thumbnail_size' ), 0, array( 'class' => 'eme_location_image' ) ); + $replacement = wp_get_attachment_image( $location['location_image_id'], get_option( 'eme_thumbnail_size' ), 0, [ 'class' => 'eme_location_image' ] ); if ( $target == 'html' ) { $replacement = apply_filters( 'eme_general', $replacement ); } elseif ( $target == 'rss' ) { @@ -2144,7 +2144,7 @@ function eme_replace_locations_placeholders( $format, $location = '', $target = } } elseif ( preg_match( '/#_LOCATIONIMAGETHUMB\{(.+?)\}/', $result, $matches ) ) { if ( ! empty( $location['location_image_id'] ) ) { - $replacement = wp_get_attachment_image( $location['location_image_id'], $matches[1], 0, array( 'class' => 'eme_location_image' ) ); + $replacement = wp_get_attachment_image( $location['location_image_id'], $matches[1], 0, [ 'class' => 'eme_location_image' ] ); if ( $target == 'html' ) { $replacement = apply_filters( 'eme_general', $replacement ); } elseif ( $target == 'rss' ) { @@ -2280,7 +2280,7 @@ function eme_replace_locations_placeholders( $format, $location = '', $target = } elseif ( preg_match( '/^#_LOCATIONCATEGORIES\{(.*?)\}\{(.*?)\}/', $result, $matches ) && get_option( 'eme_categories_enabled' ) ) { $include_cats = $matches[1]; $exclude_cats = $matches[2]; - $extra_conditions_arr = array(); + $extra_conditions_arr = []; $order_by = ''; if ( ! empty( $include_cats ) && eme_is_list_of_int($include_cats) ) { array_push( $extra_conditions_arr, "category_id IN ($include_cats)" ); @@ -2291,7 +2291,7 @@ function eme_replace_locations_placeholders( $format, $location = '', $target = } $extra_conditions = join( ' AND ', $extra_conditions_arr ); $categories = eme_get_location_category_names( $location['location_id'], $extra_conditions, $order_by ); - $cat_names = array(); + $cat_names = []; foreach ( $categories as $cat_name ) { if ( $target == 'html' ) { array_push( $cat_names, eme_trans_esc_html( $cat_name, $lang ) ); @@ -2314,7 +2314,7 @@ function eme_replace_locations_placeholders( $format, $location = '', $target = } elseif ( preg_match( '/^#_LOCATIONCATEGORIES_CSS\{(.*?)\}\{(.*?)\}/', $result, $matches ) && get_option( 'eme_categories_enabled' ) ) { $include_cats = $matches[1]; $exclude_cats = $matches[2]; - $extra_conditions_arr = array(); + $extra_conditions_arr = []; $order_by = ''; if ( ! empty( $exclude_cats ) && eme_is_list_of_int($include_cats)) { array_push( $extra_conditions_arr, "category_id IN ($include_cats)" ); @@ -2338,7 +2338,7 @@ function eme_replace_locations_placeholders( $format, $location = '', $target = } elseif ( preg_match( '/#_LOCATIONCATEGORYDESCRIPTIONS\{(.*?)\}\{(.*?)\}/', $result, $matches ) && get_option( 'eme_categories_enabled' ) ) { $include_cats = $matches[1]; $exclude_cats = $matches[2]; - $extra_conditions_arr = array(); + $extra_conditions_arr = []; $order_by = ''; if ( ! empty( $exclude_cats ) && eme_is_list_of_int($include_cats)) { array_push( $extra_conditions_arr, "category_id IN ($include_cats)" ); @@ -2630,9 +2630,9 @@ function eme_add_directions_form( $location ) { } function eme_global_map_json( $locations, $marker_clustering, $letter_icons ) { - $json_locations = array(); + $json_locations = []; foreach ( $locations as $location ) { - $json_location = array(); + $json_location = []; // we need lat and long, otherwise it fails if ( empty( $location['location_latitude'] ) || empty( $location['location_longitude'] ) ) { @@ -2662,14 +2662,14 @@ function eme_global_map_json( $locations, $marker_clustering, $letter_icons ) { $marker_clustering_val = ( $marker_clustering ) ? 'true' : 'false'; - $json = array( + $json = [ 'locations' => $json_locations, 'enable_zooming' => get_option( 'eme_map_zooming' ) ? 'true' : 'false', 'default_map_icon' => get_option( 'eme_location_map_icon' ), 'letter_icons' => $letter_icons ? 'true' : 'false', 'marker_clustering' => $marker_clustering_val, 'gestures' => get_option( 'eme_map_gesture_handling' ) ? 'true' : 'false', - ); + ]; return wp_json_encode( $json ); } @@ -2757,7 +2757,7 @@ function eme_locations_search_ajax() { header( 'Content-type: application/json; charset=utf-8' ); if ( isset( $_GET['id'] ) && $_GET['id'] != '' ) { $item = eme_get_location( intval( $_GET['id'] ) ); - $record = array(); + $record = []; if ( empty( $item ) ) { echo wp_json_encode( $record ); return; @@ -2782,7 +2782,7 @@ function eme_locations_search_ajax() { } function eme_locations_autocomplete_ajax( $no_wp_die = 0 ) { - $res = array(); + $res = []; if ( ! isset( $_REQUEST['q'] ) ) { echo wp_json_encode( $res ); return; @@ -2796,14 +2796,14 @@ function eme_locations_autocomplete_ajax( $no_wp_die = 0 ) { $locations = eme_search_locations( eme_sanitize_request($_REQUEST['q']) ); // change null to empty $locations = array_map( - function( $v ) { + function( $v ) { return ( is_null( $v ) ) ? '' : $v; }, - $locations + $locations ); foreach ( $locations as $item ) { - $record = array(); + $record = []; $record['location_id'] = $item['location_id']; $record['name'] = eme_trans_esc_html( $item['location_name'] ); $record['address1'] = eme_trans_esc_html( $item['location_address1'] ); @@ -2840,7 +2840,7 @@ function eme_ajax_locations_list() { $answers_table = $eme_db_prefix . ANSWERS_TBNAME; $search_name = isset( $_REQUEST['search_name'] ) ? esc_sql( $wpdb->esc_like( eme_sanitize_request( $_REQUEST['search_name'] ) ) ) : ''; $where = ''; - $where_arr = array(); + $where_arr = []; if ( ! empty( $search_name ) ) { $where_arr[] = "(locations.location_name like '%" . $search_name . "%')"; } @@ -2851,7 +2851,7 @@ function eme_ajax_locations_list() { if ( ! $wp_id ) { $ajaxResult['Result'] = 'OK'; $ajaxResult['TotalRecordCount'] = 0; - $ajaxResult['Records'] = array(); + $ajaxResult['Records'] = []; print wp_json_encode( $ajaxResult ); wp_die(); } @@ -2865,7 +2865,7 @@ function eme_ajax_locations_list() { $formfields_searchable = eme_get_searchable_formfields( 'locations' ); $formfields = eme_get_formfields( '', 'locations' ); - $jTableResult = array(); + $jTableResult = []; $start = intval( $_REQUEST['jtStartIndex'] ); $pagesize = intval( $_REQUEST['jtPageSize'] ); $sorting = ( ! empty( $_REQUEST['jtSorting'] ) && ! empty( eme_sanitize_sql_orderby( $_REQUEST['jtSorting'] ) ) ) ? 'ORDER BY ' . esc_sql( eme_sanitize_sql_orderby($_REQUEST['jtSorting'] )) : ''; @@ -2874,7 +2874,7 @@ function eme_ajax_locations_list() { $count_sql = "SELECT COUNT(*) FROM $table AS locations $where"; $sql = "SELECT locations.* FROM $table AS locations $where $sorting LIMIT $start,$pagesize"; } else { - $field_ids_arr = array(); + $field_ids_arr = []; foreach ( $formfields_searchable as $formfield ) { $field_ids_arr[] = $formfield['field_id']; } @@ -2904,13 +2904,13 @@ function eme_ajax_locations_list() { $recordCount = $wpdb->get_var( $count_sql ); $rows = $wpdb->get_results( $sql, ARRAY_A ); - $records = array(); + $records = []; foreach ( $rows as $item ) { $item = eme_get_extra_location_data( $item ); if ( empty( $item['location_name'] ) ) { $item['location_name'] = __( 'No name', 'events-made-easy' ); } - $record = array(); + $record = []; $record['location_id'] = $item['location_id']; $record['location_name'] = "" . eme_trans_esc_html( $item['location_name'] ) . ''; if ( ! $item['location_latitude'] && ! $item['location_longitude'] && get_option( 'eme_map_is_active' ) && ! $item['location_properties']['online_only'] ) { @@ -2958,7 +2958,7 @@ function eme_ajax_manage_locations() { $current_userid = get_current_user_id(); $table = $eme_db_prefix . LOCATIONS_TBNAME; check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); - $jTableResult = array(); + $jTableResult = []; if ( isset( $_POST['do_action'] ) ) { $do_action = eme_sanitize_request( $_POST['do_action'] ); switch ( $do_action ) { @@ -2981,9 +2981,9 @@ function eme_ajax_manage_locations() { } function eme_get_location_post_cfs() { - $answers = array(); + $answers = []; foreach ( $_POST as $key => $value ) { - if ( preg_match( '/^FIELD(\d+)$/', $key, $matches ) ) { + if ( preg_match( '/^FIELD(\d+)$/', eme_sanitize_request( $key ), $matches ) ) { $field_id = intval( $matches[1] ); $formfield = eme_get_formfield( $field_id ); if ( ! empty( $formfield ) && $formfield['field_purpose'] == 'locations' ) { @@ -2994,12 +2994,12 @@ function eme_get_location_post_cfs() { if ( is_array( $value ) ) { $value = eme_convert_array2multi( $value ); } - $answer = array( + $answer = [ 'field_name' => $formfield['field_name'], 'field_id' => $field_id, 'extra_charge' => $formfield['extra_charge'], 'answer' => $value, - ); + ]; $answers[] = $answer; } } @@ -3024,7 +3024,7 @@ function eme_get_location_answers( $location_id ) { } function eme_location_store_cf_answers( $location_id ) { - $answer_ids_seen = array(); + $answer_ids_seen = []; $all_answers = eme_get_location_answers( $location_id ); $found_answers = eme_get_location_post_cfs(); @@ -3053,7 +3053,7 @@ function eme_location_store_cf_answers( $location_id ) { function eme_get_cf_location_ids( $val, $field_id, $is_multi = 0 ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . ANSWERS_TBNAME; - $conditions = array(); + $conditions = []; $val = eme_kses( $val ); if ( is_array( $val ) ) { diff --git a/eme-mailer.php b/eme-mailer.php index 3acb9f5b..f7aea15d 100644 --- a/eme-mailer.php +++ b/eme-mailer.php @@ -9,14 +9,14 @@ function eme_set_wpmail_html_content_type() { } // for backwards compat, the fromname and email are after the replyto and can be empty -function eme_send_mail( $subject, $body, $receiveremail, $receivername = '', $replytoemail = '', $replytoname = '', $fromemail = '', $fromname = '', $atts = array(), $custom_headers = array() ) { +function eme_send_mail( $subject, $body, $receiveremail, $receivername = '', $replytoemail = '', $replytoname = '', $fromemail = '', $fromname = '', $atts = [], $custom_headers = [] ) { $subject = preg_replace( '/(^\s+|\s+$)/m', '', $subject ); $res = true; $message = ''; // nothing to send? Then act as if all is ok if ( empty( $body ) || empty( $subject ) || empty( $receiveremail ) ) { - return array( $res, $message ); + return [ $res, $message ]; } // the next 8 lines are no longer needed, but best to keep for mails already queued before this release (2.3.8) @@ -31,7 +31,7 @@ function eme_send_mail( $subject, $body, $receiveremail, $receivername = '', $re // get all mail options, put them in an array and apply filter // if you change this array, don't forget to update the doc - $mailoptions = array( + $mailoptions = [ 'fromMail' => $fromemail, 'fromName' => $fromname, 'toMail' => $receiveremail, @@ -49,7 +49,7 @@ function eme_send_mail( $subject, $body, $receiveremail, $receivername = '', $re 'smtp_username' => get_option( 'eme_smtp_username', '' ), 'smtp_password' => get_option( 'eme_smtp_password', '' ), 'smtp_debug' => get_option( 'eme_smtp_debug' ), // true or false - ); + ]; $mailoptions = apply_filters( 'eme_filter_mail_options', $mailoptions ); if ( empty( $mailoptions['smtp_host'] ) ) { @@ -62,7 +62,7 @@ function eme_send_mail( $subject, $body, $receiveremail, $receivername = '', $re $bcc_addresses = preg_split( '/,|;/', $mailoptions['bcc_addresses'] ); // allow either an array of file paths or of attachment ids - $attachment_paths_arr = array(); + $attachment_paths_arr = []; foreach ( $atts as $attachment ) { if ( ! empty( $attachment ) ) { if ( is_numeric( $attachment ) ) { @@ -79,7 +79,7 @@ function eme_send_mail( $subject, $body, $receiveremail, $receivername = '', $re } } - if ( ! in_array( $mailoptions['mail_send_method'], array( 'smtp', 'mail', 'sendmail', 'qmail', 'wp_mail' ) ) ) { + if ( ! in_array( $mailoptions['mail_send_method'], [ 'smtp', 'mail', 'sendmail', 'qmail', 'wp_mail' ] ) ) { $mailoptions['mail_send_method'] = 'wp_mail'; } @@ -209,13 +209,13 @@ function eme_send_mail( $subject, $body, $receiveremail, $receivername = '', $re // so now we disable cert verification as requested and allow self signed // but only for ip's in the reserved range if ( $in_reserved_range ) { - $mail->SMTPOptions = array( - 'ssl' => array( + $mail->SMTPOptions = [ + 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, - ), - ); + ], + ]; } } @@ -277,14 +277,14 @@ function eme_send_mail( $subject, $body, $receiveremail, $receivername = '', $re } // remove the phpmailer url added for some errors $message = str_replace( 'https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting', '', $message ); - return array( $res, $message ); + return [ $res, $message ]; } -function eme_db_insert_ongoing_mailing( $mailing_name, $subject, $body, $fromemail, $fromname, $replytoemail, $replytoname, $mail_text_html, $conditions = array() ) { +function eme_db_insert_ongoing_mailing( $mailing_name, $subject, $body, $fromemail, $fromname, $replytoemail, $replytoname, $mail_text_html, $conditions = [] ) { global $wpdb,$eme_db_prefix; $mailing_table = $eme_db_prefix . MAILINGS_TBNAME; $now = current_time( 'mysql', false ); - $mailing = array( + $mailing = [ 'name' => mb_substr( $mailing_name, 0, 255 ), 'planned_on' => $now, 'status' => 'ongoing', @@ -297,7 +297,7 @@ function eme_db_insert_ongoing_mailing( $mailing_name, $subject, $body, $fromema 'mail_text_html' => $mail_text_html, 'creation_date' => $now, 'conditions' => eme_serialize( $conditions ), - ); + ]; if ( $wpdb->insert( $mailing_table, $mailing ) === false ) { return false; } else { @@ -309,7 +309,7 @@ function eme_db_insert_mailing( $mailing_name, $planned_on, $subject, $body, $fr global $wpdb,$eme_db_prefix; $mailing_table = $eme_db_prefix . MAILINGS_TBNAME; $now = current_time( 'mysql', false ); - $mailing = array( + $mailing = [ 'name' => mb_substr( $mailing_name, 0, 255 ), 'planned_on' => $planned_on, 'status' => 'initial', @@ -322,7 +322,7 @@ function eme_db_insert_mailing( $mailing_name, $planned_on, $subject, $body, $fr 'mail_text_html' => $mail_text_html, 'creation_date' => $now, 'conditions' => eme_serialize( $conditions ), - ); + ]; if ( $wpdb->insert( $mailing_table, $mailing ) === false ) { return false; } else { @@ -330,11 +330,11 @@ function eme_db_insert_mailing( $mailing_name, $planned_on, $subject, $body, $fr } } -function eme_queue_fastmail( $subject, $body, $fromemail, $fromname, $receiveremail, $receivername, $replytoemail, $replytoname, $mailing_id = 0, $person_id = 0, $member_id = 0, $atts = array() ) { +function eme_queue_fastmail( $subject, $body, $fromemail, $fromname, $receiveremail, $receivername, $replytoemail, $replytoname, $mailing_id = 0, $person_id = 0, $member_id = 0, $atts = [] ) { return eme_queue_mail( $subject, $body, $fromemail, $fromname, $receiveremail, $receivername, $replytoemail, $replytoname, $mailing_id, $person_id, $member_id, $atts, 1 ); } -function eme_queue_mail( $subject, $body, $fromemail, $fromname, $receiveremail, $receivername, $replytoemail, $replytoname, $mailing_id = 0, $person_id = 0, $member_id = 0, $atts = array(), $send_immediately = 0 ) { +function eme_queue_mail( $subject, $body, $fromemail, $fromname, $receiveremail, $receivername, $replytoemail, $replytoname, $mailing_id = 0, $person_id = 0, $member_id = 0, $atts = [], $send_immediately = 0 ) { global $wpdb,$eme_db_prefix; $mqueue_table = $eme_db_prefix . MQUEUE_TBNAME; @@ -348,7 +348,7 @@ function eme_queue_mail( $subject, $body, $fromemail, $fromname, $receiveremail, } $random_id = eme_random_id(); - $custom_headers = array( 'X-EME-mailid:' . $random_id ); + $custom_headers = [ 'X-EME-mailid:' . $random_id ]; if ( ! get_option( 'eme_queue_mails' ) ) { $send_immediately = 1; } @@ -363,7 +363,7 @@ function eme_queue_mail( $subject, $body, $fromemail, $fromname, $receiveremail, } $now = current_time( 'mysql', false ); - $mail = array( + $mail = [ 'subject' => mb_substr( $subject, 0, 255 ), 'body' => $body, 'fromemail' => $fromemail, @@ -378,7 +378,7 @@ function eme_queue_mail( $subject, $body, $fromemail, $fromname, $receiveremail, 'attachments' => eme_serialize( $atts ), 'creation_date' => $now, 'random_id' => $random_id, - ); + ]; if ( $send_immediately ) { // we add the mail to the queue as sent and send it immediately $mail['status'] = 1; @@ -395,8 +395,8 @@ function eme_queue_mail( $subject, $body, $fromemail, $fromname, $receiveremail, function eme_mark_mail_ignored( $id ) { global $wpdb,$eme_db_prefix; $mqueue_table = $eme_db_prefix . MQUEUE_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['id'] = intval( $id ); $fields['status'] = 4; $fields['sent_datetime'] = current_time( 'mysql', false ); @@ -410,8 +410,8 @@ function eme_mark_mail_ignored( $id ) { function eme_mark_mail_sent( $id ) { global $wpdb,$eme_db_prefix; $mqueue_table = $eme_db_prefix . MQUEUE_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['id'] = intval( $id ); $fields['status'] = 1; $fields['sent_datetime'] = current_time( 'mysql', false ); @@ -425,8 +425,8 @@ function eme_mark_mail_sent( $id ) { function eme_mark_mail_fail( $id, $error_msg = '' ) { global $wpdb,$eme_db_prefix; $mqueue_table = $eme_db_prefix . MQUEUE_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['id'] = intval( $id ); $fields['status'] = 2; $fields['error_msg'] = esc_sql( $error_msg ); @@ -530,7 +530,7 @@ function eme_send_queued() { $body .= $track_html; } } - $custom_headers = array( 'X-EME-mailid:' . $mail['random_id'] ); + $custom_headers = [ 'X-EME-mailid:' . $mail['random_id'] ]; $mail_res_arr = eme_send_mail( $mail['subject'], $body, $mail['receiveremail'], $mail['receivername'], $mail['replytoemail'], $mail['replytoname'], $mail['fromemail'], $mail['fromname'], $atts, $custom_headers ); if ( $mail_res_arr[0] ) { eme_mark_mail_sent( $mail['id'] ); @@ -704,23 +704,23 @@ function eme_get_mailings( $archive = 0 ) { } function eme_mail_states() { - $states = array( + $states = [ 0 => 'planned', 1 => 'sent', 2 => 'failed', 3 => 'cancelled', 4 => 'ignored', - ); + ]; return $states; } function eme_mail_localizedstates() { - $states = array( + $states = [ 0 => __( 'Planned', 'events-made-easy' ), 1 => __( 'Sent', 'events-made-easy' ), 2 => __( 'Failed', 'events-made-easy' ), 3 => __( 'Cancelled', 'events-made-easy' ), 4 => __( 'Ignored', 'events-made-easy' ), - ); + ]; return $states; } @@ -736,14 +736,14 @@ function eme_get_mailing_stats( $mailing_id = 0 ) { $table = $eme_db_prefix . MQUEUE_TBNAME; $sql = "SELECT COUNT(*) AS count,status FROM $table WHERE mailing_id=$mailing_id GROUP BY mailing_id,status"; $lines = $wpdb->get_results( $sql, ARRAY_A ); - $res = array( + $res = [ 'planned' => 0, 'sent' => 0, 'failed' => 0, 'cancelled' => 0, 'ignored' => 0, 'total_read_count' => 0, - ); + ]; $states = eme_mail_states(); foreach ( $lines as $line ) { $status = $states[ $line['status'] ]; @@ -837,28 +837,28 @@ function eme_update_mailing_receivers( $mail_subject, $mail_message, $from_email $res['not_sent'] = ''; $mail_subject = eme_replace_generic_placeholders( $mail_subject ); $mail_message = eme_replace_generic_placeholders( $mail_message ); - $not_sent = array(); - $emails_handled = array(); + $not_sent = []; + $emails_handled = []; if ( isset( $conditions['ignore_massmail_setting'] ) && $conditions['ignore_massmail_setting'] == 1 ) { $ignore_massmail_setting = 1; } else { $ignore_massmail_setting = 0; } - $atts = array(); + $atts = []; $attachment_ids = ''; if ( $conditions['action'] == 'genericmail' ) { - $person_ids = array(); - $member_ids = array(); - $cond_person_ids_arr = array(); - $cond_member_ids_arr = array(); + $person_ids = []; + $member_ids = []; + $cond_person_ids_arr = []; + $cond_member_ids_arr = []; if ( isset( $conditions['eme_generic_attach_ids'] ) ) { $attachment_ids = $conditions['eme_generic_attach_ids']; } if ( ! empty( $attachment_ids ) ) { $attachment_id_arr = explode( ',', $attachment_ids ); } else { - $attachment_id_arr = array(); + $attachment_id_arr = []; } if ( isset( $conditions['eme_send_all_people'] ) ) { @@ -961,7 +961,7 @@ function eme_update_mailing_receivers( $mail_subject, $mail_message, $from_email if ( ! empty( $attachment_ids ) ) { $attachment_id_arr = explode( ',', $attachment_ids ); } else { - $attachment_id_arr = array(); + $attachment_id_arr = []; } if ( empty( $event ) ) { @@ -998,8 +998,8 @@ function eme_update_mailing_receivers( $mail_subject, $mail_message, $from_email } } } elseif ( $conditions['eme_mail_type'] == 'all_people' || $conditions['eme_mail_type'] == 'people_and_groups' || $conditions['eme_mail_type'] == 'all_people_not_registered' ) { - $person_ids = array(); - $member_ids = array(); + $person_ids = []; + $member_ids = []; if ( $conditions['eme_mail_type'] == 'all_people' || $conditions['eme_mail_type'] == 'all_people_not_registered' ) { // although we check later on the massmail preference per person too, we optimize the sql load a bit if ( $ignore_massmail_setting ) { @@ -1028,7 +1028,7 @@ function eme_update_mailing_receivers( $mail_subject, $mail_message, $from_email if ( ! empty( $conditions['exclude_registered'] ) || $conditions['eme_mail_type'] == 'all_people_not_registered' ) { $registered_ids = eme_get_attendee_ids( $conditions['event_id'] ); } else { - $registered_ids = array(); + $registered_ids = []; } foreach ( $member_ids as $member_id ) { $member = eme_get_member( $member_id ); @@ -1089,7 +1089,7 @@ function eme_update_mailing_receivers( $mail_subject, $mail_message, $from_email if ( $conditions['eme_mail_type'] == 'all_wp_not_registered' || $conditions['exclude_registered'] ) { $attendee_wp_ids = eme_get_wp_ids_for( $conditions['event_id'] ); } else { - $attendee_wp_ids = array(); + $attendee_wp_ids = []; } $lang = eme_detect_lang(); foreach ( $wp_users as $wp_user ) { @@ -1122,7 +1122,7 @@ function eme_mailingreport_list() { check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); if ( ! current_user_can( get_option( 'eme_cap_send_mails' ) ) ) { - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'Error'; $ajaxResult['Message'] = __( 'Access denied!', 'events-made-easy' ); print wp_json_encode( $ajaxResult ); @@ -1136,7 +1136,7 @@ function eme_mailingreport_list() { $mailing_id = intval( $_REQUEST['mailing_id'] ); $search_name = isset( $_REQUEST['search_name'] ) ? esc_sql( $wpdb->esc_like( eme_sanitize_request( $_REQUEST['search_name'] ) ) ) : ''; $where = ''; - $where_arr = array(); + $where_arr = []; $where_arr[] = '(mailing_id=' . intval( $_REQUEST['mailing_id'] ) . ')'; if ( ! empty( $search_name ) ) { $where_arr[] = "(receivername like '%$search_name%' OR receiveremail like '%$search_name%')"; @@ -1146,7 +1146,7 @@ function eme_mailingreport_list() { $where = ' WHERE ' . implode( ' AND ', $where_arr ); } - $jTableResult = array(); + $jTableResult = []; $sql = "SELECT COUNT(*) FROM $table $where"; $recordCount = $wpdb->get_var( $sql ); $start = ( isset( $_REQUEST['jtStartIndex'] ) ) ? intval( $_REQUEST['jtStartIndex'] ) : 0; @@ -1154,10 +1154,10 @@ function eme_mailingreport_list() { $sorting = ( ! empty( $_REQUEST['jtSorting'] ) && ! empty( eme_sanitize_sql_orderby( $_REQUEST['jtSorting'] ) ) ) ? 'ORDER BY ' . esc_sql( $_REQUEST['jtSorting'] ) : ''; $sql = "SELECT * FROM $table $where $sorting LIMIT $start,$pagesize"; $rows = $wpdb->get_results( $sql, ARRAY_A ); - $records = array(); + $records = []; $states = eme_mail_localizedstates(); foreach ( $rows as $item ) { - $record = array(); + $record = []; $id = $item['id']; $record['receiveremail'] = $item['receiveremail']; $record['receivername'] = $item['receivername']; @@ -1231,8 +1231,8 @@ function eme_send_mails_ajax_actions( $action ) { wp_die(); } $event_ids = isset( $_POST['event_ids'] ) ? wp_parse_id_list($_POST['event_ids']) : 0; - $ajaxResult = array(); - $conditions = array(); + $ajaxResult = []; + $conditions = []; $eme_date_obj_now = new ExpressiveDate( 'now', $eme_timezone ); if ( $action == 'searchmail' ) { @@ -1430,7 +1430,7 @@ function eme_send_mails_ajax_actions( $action ) { if ( ! empty( $attachment_ids ) ) { $attachment_ids_arr = explode( ',', $attachment_ids ); } else { - $attachment_ids_arr = array(); + $attachment_ids_arr = []; } $preview_mail_to = intval( $_POST['send_previewmailto_id'] ); if ( $preview_mail_to == 0 ) { @@ -1592,7 +1592,7 @@ function eme_send_mails_ajax_actions( $action ) { if ( ! empty( $attachment_ids ) ) { $attachment_ids_arr = explode( ',', $attachment_ids ); } else { - $attachment_ids_arr = array(); + $attachment_ids_arr = []; } $preview_mail_to = intval( $_POST['send_previeweventmailto_id'] ); if ( $preview_mail_to == 0 ) { @@ -1663,7 +1663,7 @@ function eme_send_mails_ajax_actions( $action ) { $current_userid = get_current_user_id(); $mail_problems = 0; $mail_access_problems = 0; - $not_sent = array(); + $not_sent = []; $count_event_ids = count( $event_ids ); foreach ( $event_ids as $event_id ) { $conditions['event_id'] = $event_id; @@ -1743,13 +1743,13 @@ function eme_emails_page() { $eme_queue_mails_configured = 1; } - $mygroups = array(); - $mymembergroups = array(); - $person_ids = array(); - $membership_ids = array(); - $persongroup_ids = array(); - $membergroup_ids = array(); - $member_ids = array(); + $mygroups = []; + $mymembergroups = []; + $person_ids = []; + $membership_ids = []; + $persongroup_ids = []; + $membergroup_ids = []; + $member_ids = []; // if we get a request for mailings, set the active tab to the 'tab-genericmails' tab (which is index 1) if ( isset( $_POST['eme_admin_action'] ) && $_POST['eme_admin_action'] == 'new_mailing' ) { $data_forced_tab = 'data-showtab=1'; diff --git a/eme-members.php b/eme-members.php index 66fc17be..e347909a 100644 --- a/eme-members.php +++ b/eme-members.php @@ -9,21 +9,21 @@ function eme_new_membership() { $eme_date_obj_now = new ExpressiveDate( 'now', $eme_timezone ); $today = $eme_date_obj_now->getDate(); - $membership = array( + $membership = [ 'name' => '', 'description' => '', 'type' => '', // fixed/rolling 'start_date' => $today, // only for fixed 'duration_count' => 1, 'duration_period' => 'years', - ); + ]; $membership['properties'] = eme_init_membership_props(); return $membership; } function eme_new_member() { - $member = array( + $member = [ 'membership_id' => 0, 'person_id' => 0, 'related_member_id' => 0, @@ -38,14 +38,14 @@ function eme_new_member() { 'payment_date' => '0000-00-00 00:00', 'discount' => '', 'discountids' => '', - 'dcodes_entered' => array(), - 'dcodes_used' => array(), + 'dcodes_entered' => [], + 'dcodes_used' => [], 'dgroupid' => 0, - ); + ]; return $member; } -function eme_init_membership_props( $props = array() ) { +function eme_init_membership_props( $props = [] ) { if ( ! isset( $props['reminder_days'] ) ) { $props['reminder_days'] = ''; } else { @@ -82,10 +82,10 @@ function eme_init_membership_props( $props = array() ) { $props['family_membership'] = 0; } if ( ! isset( $props['addpersontogroup'] ) ) { - $props['addpersontogroup'] = array(); + $props['addpersontogroup'] = []; } if ( ! isset( $props['dyndata'] ) ) { - $props['dyndata'] = array(); + $props['dyndata'] = []; } if ( ! isset( $props['dyndata_all_fields'] ) ) { $props['dyndata_all_fields'] = 0; @@ -166,13 +166,13 @@ function eme_init_membership_props( $props = array() ) { $props['contact_paid_subject_format'] = __( 'Member payment received', 'events-made-easy' ); } - $templates = array( 'member_form_tpl', 'familymember_form_tpl', 'payment_form_header_tpl', 'payment_form_footer_tpl', 'new_body_format_tpl', 'updated_body_format_tpl', 'extended_body_format_tpl', 'paid_body_format_tpl', 'reminder_body_format_tpl', 'stop_body_format_tpl', 'contact_new_body_format_tpl', 'contact_stop_body_format_tpl', 'contact_ipn_body_format_tpl', 'contact_paid_body_format_tpl', 'offline_payment_tpl', 'member_added_tpl', 'payment_success_tpl' ); + $templates = [ 'member_form_tpl', 'familymember_form_tpl', 'payment_form_header_tpl', 'payment_form_footer_tpl', 'new_body_format_tpl', 'updated_body_format_tpl', 'extended_body_format_tpl', 'paid_body_format_tpl', 'reminder_body_format_tpl', 'stop_body_format_tpl', 'contact_new_body_format_tpl', 'contact_stop_body_format_tpl', 'contact_ipn_body_format_tpl', 'contact_paid_body_format_tpl', 'offline_payment_tpl', 'member_added_tpl', 'payment_success_tpl' ]; foreach ( $templates as $template ) { if ( ! isset( $props[ $template ] ) ) { $props[ $template ] = 0; } } - $template_texts = array( 'member_form_text', 'familymember_form_text', 'payment_form_header_text', 'payment_form_footer_text', 'payment_success_text', 'offline_payment_text', 'new_body_text', 'contact_new_body_text', 'updated_body_text', 'extended_body_text', 'paid_body_text', 'contact_paid_body_text', 'reminder_body_text', 'stop_body_text', 'contact_stop_body_text', 'contact_ipn_body_text', 'member_added_text' ); + $template_texts = [ 'member_form_text', 'familymember_form_text', 'payment_form_header_text', 'payment_form_footer_text', 'payment_success_text', 'offline_payment_text', 'new_body_text', 'contact_new_body_text', 'updated_body_text', 'extended_body_text', 'paid_body_text', 'contact_paid_body_text', 'reminder_body_text', 'stop_body_text', 'contact_stop_body_text', 'contact_ipn_body_text', 'member_added_text' ]; foreach ( $template_texts as $template_text ) { if ( ! isset( $props[ $template_text ] ) ) { $props[ $template_text ] = ''; @@ -251,7 +251,7 @@ function eme_db_insert_member( $line, $membership, $member_id = 0 ) { function eme_db_update_member( $member_id, $line, $membership, $update_answers = 1 ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . MEMBERS_TBNAME; - $where = array(); + $where = []; $where['member_id'] = intval( $member_id ); $tmp_member = eme_get_member( $member_id ); @@ -299,7 +299,7 @@ function eme_db_update_member( $member_id, $line, $membership, $update_answers = function eme_db_update_membership( $membership_id, $line ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . MEMBERSHIPS_TBNAME; - $where = array(); + $where = []; $where['membership_id'] = intval( $membership_id ); $membership = eme_get_membership( $membership_id ); @@ -324,10 +324,10 @@ function eme_db_update_membership( $membership_id, $line ) { function eme_update_member_lastseen( $member_id ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . MEMBERS_TBNAME; - $where = array(); + $where = []; $where['member_id'] = intval( $member_id ); - $fields = array(); + $fields = []; $fields['last_seen'] = current_time( 'mysql', false ); $wpdb->update( $table, $fields, $where ); } @@ -337,14 +337,14 @@ function eme_get_members( $member_ids, $extra_search = '' ) { $people_table = $eme_db_prefix . PEOPLE_TBNAME; $members_table = $eme_db_prefix . MEMBERS_TBNAME; $memberships_table = $eme_db_prefix . MEMBERSHIPS_TBNAME; - $lines = array(); + $lines = []; if ( ! empty( $member_ids ) && eme_array_integers( $member_ids ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($member_ids), '%d')); $sql = $wpdb->prepare("SELECT members.*, people.lastname, people.firstname, people.email, memberships.name AS membership_name FROM $members_table AS members LEFT JOIN $memberships_table AS memberships ON members.membership_id=memberships.membership_id LEFT JOIN $people_table AS people ON members.person_id=people.person_id - WHERE members.member_id IN ($commaDelimitedPlaceholders)",$member_ids); + WHERE members.member_id IN ($commaDelimitedPlaceholders)", $member_ids); if ( ! empty( $extra_search ) ) { $sql .= " AND $extra_search"; } @@ -406,22 +406,22 @@ function eme_get_membership( $id ) { } function eme_membership_types() { - $type_array = array( + $type_array = [ 'fixed' => __( 'Fixed startdate', 'events-made-easy' ), 'rolling' => __( 'Rolling period', 'events-made-easy' ), - ); + ]; return $type_array; } function eme_membership_durations() { - $duration_array = array( + $duration_array = [ '' => '', 'days' => __( 'Days', 'events-made-easy' ), 'weeks' => __( 'Weeks', 'events-made-easy' ), 'months' => __( 'Months', 'events-made-easy' ), 'years' => __( 'Years', 'events-made-easy' ), 'forever' => __( 'Forever', 'events-made-easy' ), - ); + ]; return $duration_array; } @@ -434,12 +434,12 @@ function eme_get_member( $id ) { if ( eme_is_serialized( $member['dcodes_used'] ) ) { $member['dcodes_used'] = eme_unserialize( $member['dcodes_used'] ); } else { - $member['dcodes_used'] = array(); + $member['dcodes_used'] = []; } if ( eme_is_serialized( $member['dcodes_entered'] ) ) { $member['dcodes_entered'] = eme_unserialize( $member['dcodes_entered'] ); } else { - $member['dcodes_entered'] = array(); + $member['dcodes_entered'] = []; } } return $member; @@ -456,12 +456,12 @@ function eme_get_active_member_by_personid_membershipid( $person_id, $membership if ( eme_is_serialized( $member['dcodes_used'] ) ) { $member['dcodes_used'] = eme_unserialize( $member['dcodes_used'] ); } else { - $member['dcodes_used'] = array(); + $member['dcodes_used'] = []; } if ( eme_is_serialized( $member['dcodes_entered'] ) ) { $member['dcodes_entered'] = eme_unserialize( $member['dcodes_entered'] ); } else { - $member['dcodes_entered'] = array(); + $member['dcodes_entered'] = []; } } return $member; @@ -486,12 +486,12 @@ function eme_get_member_by_wpid_membershipid( $wp_id, $membership_id, $status = if ( eme_is_serialized( $member['dcodes_used'] ) ) { $member['dcodes_used'] = eme_unserialize( $member['dcodes_used'] ); } else { - $member['dcodes_used'] = array(); + $member['dcodes_used'] = []; } if ( eme_is_serialized( $member['dcodes_entered'] ) ) { $member['dcodes_entered'] = eme_unserialize( $member['dcodes_entered'] ); } else { - $member['dcodes_entered'] = array(); + $member['dcodes_entered'] = []; } } @@ -686,7 +686,7 @@ function eme_memberships_page() { $message = __( 'You have no right to manage memberships!', 'events-made-easy' ); } elseif ( isset( $_POST['eme_admin_action'] ) && $_POST['eme_admin_action'] == 'do_addmembership' ) { check_admin_referer( 'eme_admin', 'eme_admin_nonce' ); - list($membership_id,$res_text) = eme_add_update_membership(); + [$membership_id, $res_text] = eme_add_update_membership(); if ( $membership_id ) { $message = __( 'Membership added', 'events-made-easy' ); if ( get_option( 'eme_stay_on_edit_page' ) || ! empty( $res_text ) ) { @@ -703,7 +703,7 @@ function eme_memberships_page() { } elseif ( isset( $_POST['eme_admin_action'] ) && $_POST['eme_admin_action'] == 'do_editmembership' ) { check_admin_referer( 'eme_admin', 'eme_admin_nonce' ); $membership_id = intval( $_POST['membership_id'] ); - list($res,$res_text) = eme_add_update_membership( $membership_id ); + [$res, $res_text] = eme_add_update_membership( $membership_id ); if ( $res ) { $message = __( 'Membership updated', 'events-made-easy' ); if ( get_option( 'eme_stay_on_edit_page' ) || ! empty( $res_text ) ) { @@ -737,7 +737,7 @@ function eme_memberships_page() { } function eme_add_update_member( $member_id = 0 ) { - $member = array(); + $member = []; $payment_id = 0; $membership_id = 0; $transfer = 0; @@ -751,6 +751,7 @@ function eme_add_update_member( $member_id = 0 ) { $membership_id = intval( $_POST['transferto_membershipid'] ); // move all data from the original membership in $_POST to the new membership id too, so other membership code (like eme_store_member_answers) can work as expected with the new membership id foreach ( $_POST as $key => $val ) { + $key = eme_sanitize_request( $key ); if ( is_array( $_POST[ $key ] ) && isset( $_POST[ $key ][ $orig_membership_id ] ) ) { $_POST[ $key ][ $membership_id ] = eme_sanitize_request( $_POST[ $key ][ $orig_membership_id ] ); } @@ -834,9 +835,9 @@ function eme_add_update_member( $member_id = 0 ) { // if we're updaing the head of the family, change the family members $related_member_ids = eme_get_family_member_ids( $member_id ); if ( ! empty( $related_member_ids ) ) { - $fields_to_copy = array( 'start_date', 'end_date', 'paid', 'payment_date', 'status', 'status_automatic', 'reminder', 'reminder_date', 'pg', 'pg_pid' ); + $fields_to_copy = [ 'start_date', 'end_date', 'paid', 'payment_date', 'status', 'status_automatic', 'reminder', 'reminder_date', 'pg', 'pg_pid' ]; foreach ( $related_member_ids as $related_member_id ) { - $related_member = array(); + $related_member = []; foreach ( $fields_to_copy as $field_to_copy ) { $related_member[ $field_to_copy ] = $member[ $field_to_copy ]; } @@ -889,10 +890,11 @@ function eme_add_update_member( $member_id = 0 ) { $person_id = $res[0]; $err = $res[1]; // now add the family members - $familymember_person_ids = array(); + $familymember_person_ids = []; if ( $person_id ) { if ( isset( $_POST['familymember'] ) ) { foreach ( $_POST['familymember'] as $familymember ) { + // sanitizing happens in eme_add_familymember_from_frontend $familymember_person_ids[] = eme_add_familymember_from_frontend( $person_id, $familymember ); } } @@ -964,7 +966,7 @@ function eme_add_update_member( $member_id = 0 ) { // now for the familymembers, we need to do this before we send out the newMember mail, otherwise the info // concerning related family members (#_FAMILYCOUNT and #_FAMILYMEMBERS) is not correctly replaced $familymember_person_ids = eme_get_family_person_ids( $person_id ); - $fields_to_copy = array( 'start_date', 'end_date', 'paid', 'payment_date', 'status', 'status_automatic', 'reminder', 'reminder_date', 'pg', 'pg_pid' ); + $fields_to_copy = [ 'start_date', 'end_date', 'paid', 'payment_date', 'status', 'status_automatic', 'reminder', 'reminder_date', 'pg', 'pg_pid' ]; foreach ( $familymember_person_ids as $familymember_person_id ) { $familymember_id = eme_is_member( $familymember_person_id, $membership_id ); if ( $familymember_id ) { @@ -978,7 +980,7 @@ function eme_add_update_member( $member_id = 0 ) { $familymember['unique_nbr'] = ''; eme_db_update_member( $familymember_id, $familymember, $membership ); } else { - $familymember = array(); + $familymember = []; $familymember['person_id'] = $familymember_person_id; $familymember['related_member_id'] = $member_id; foreach ( $fields_to_copy as $field_to_copy ) { @@ -1026,10 +1028,10 @@ function eme_add_update_member( $member_id = 0 ) { } else { $result = __( 'Problem detected while adding personal info: at least last name, first name and email need to be present', 'events-made-easy' ); } - $res = array( + $res = [ 0 => $result, 1 => $payment_id, - ); + ]; return $res; } @@ -1088,8 +1090,8 @@ function eme_memberships_exists( $ids_arr ) { } function eme_add_update_membership( $membership_id = 0 ) { - $membership = array(); - $properties = array(); + $membership = []; + $properties = []; $message = ''; $membership['name'] = isset( $_POST['name'] ) ? eme_sanitize_request( $_POST['name'] ) : ''; @@ -1101,7 +1103,7 @@ function eme_add_update_membership( $membership_id = 0 ) { $membership['properties'] = eme_kses( $_POST['properties'] ); } // now for the select boxes, we need to set to 0 if not in the _POST - $select_post_vars = array( 'use_captcha', 'use_recaptcha', 'use_hcaptcha', 'create_wp_user' ); + $select_post_vars = [ 'use_captcha', 'use_recaptcha', 'use_hcaptcha', 'create_wp_user' ]; foreach ( $select_post_vars as $post_var ) { if ( ! isset( $_POST['properties'][ $post_var ] ) ) { $membership['properties'][ $post_var ] = 0; @@ -1163,7 +1165,7 @@ function eme_add_update_membership( $membership_id = 0 ) { if ( $membership_id ) { eme_membership_store_answers( $membership_id ); } - return array( $membership_id, $message ); + return [ $membership_id, $message ]; } function eme_member_edit_layout( $member, $limited = 0 ) { @@ -1562,13 +1564,13 @@ function eme_meta_box_div_membershipdetails( $membership, $is_new_membership ) { $create_wp_user = ( $membership['properties']['create_wp_user'] ) ? "checked='checked'" : ''; $membership_discount = ( $membership['properties']['discount'] ) ? $membership['properties']['discount'] : ''; $membership_discountgroup = ( $membership['properties']['discountgroup'] ) ? $membership['properties']['discountgroup'] : ''; - $discount_arr = array(); - $dgroup_arr = array(); + $discount_arr = []; + $dgroup_arr = []; if ( ! empty( $membership_discount ) ) { - $discount_arr = array( $membership_discount => eme_get_discount_name( $membership_discount ) ); + $discount_arr = [ $membership_discount => eme_get_discount_name( $membership_discount ) ]; } if ( ! empty( $membership_discountgroup ) ) { - $dgroup_arr = array( $membership_discountgroup => eme_get_dgroup_name( $membership_discountgroup ) ); + $dgroup_arr = [ $membership_discountgroup => eme_get_dgroup_name( $membership_discountgroup ) ]; } ?> @@ -1702,11 +1704,11 @@ function eme_meta_box_div_membershipdetails( $membership, $is_new_membership ) { 'properties[contact_id]', 'show_option_none' => __( 'WP Admin', 'events-made-easy' ), 'selected' => $membership['properties']['contact_id'], - ) + ] ); ?> @@ -1916,13 +1918,13 @@ function eme_meta_box_div_membershipdetails( $membership, $is_new_membership ) { if ( isset( $membership['properties']['dyndata'] ) ) { $eme_data = $membership['properties']['dyndata']; } else { - $eme_data = array(); + $eme_data = []; } // for new memberships there's no membership id if ( isset( $membership['membership_id'] ) ) { $used_groupingids = eme_get_membership_cf_answers_groupingids( $membership['membership_id'] ); } else { - $used_groupingids = array(); + $used_groupingids = []; } eme_dyndata_adminform( $eme_data, $templates_array, $used_groupingids ); $eme_membership_dyndata_all_fields = ( $membership['properties']['dyndata_all_fields'] ) ? "checked='checked'" : ''; @@ -2335,7 +2337,7 @@ function eme_meta_box_div_membershipcustomfields( $membership ) { if ( ! empty( $membership['membership_id'] ) ) { $answers = eme_get_membership_answers( $membership['membership_id'] ); } else { - $answers = array(); + $answers = []; } foreach ( $formfields as $formfield ) { $field_name = eme_trans_esc_html( $formfield['field_name'] ); @@ -2367,7 +2369,7 @@ function eme_meta_box_div_membershipcustomfields( $membership ) {
    $value ) { if ( preg_match( '/^DISCOUNT/', $key, $matches ) ) { @@ -2839,18 +2841,18 @@ function eme_calc_memberprice_ajax() { $membership_id = $member['membership_id']; } if ( ! $membership_id ) { - echo wp_json_encode( array( 'total' => '' ) ); + echo wp_json_encode( [ 'total' => '' ] ); return; } $membership = eme_get_membership( $membership_id ); if ( ! $membership ) { - echo wp_json_encode( array( 'total' => '' ) ); + echo wp_json_encode( [ 'total' => '' ] ); return; } $total = eme_calc_price_fake_member( $membership ); $cur = $membership['properties']['currency']; $result = eme_localized_price( $total, $cur ); - echo wp_json_encode( array( 'total' => $result ) ); + echo wp_json_encode( [ 'total' => $result ] ); } function eme_dyndata_familymember_ajax() { @@ -2874,7 +2876,7 @@ function eme_dyndata_familymember_ajax() { for ( $i = 1;$i <= $count;$i++ ) { $form_html .= eme_replace_membership_familyformfields_placeholders( $format, $i ); } - echo wp_json_encode( array( 'Result' => do_shortcode( $form_html ) ) ); + echo wp_json_encode( [ 'Result' => do_shortcode( $form_html ) ] ); } function eme_dyndata_member_ajax() { @@ -2889,7 +2891,7 @@ function eme_dyndata_member_ajax() { $member = eme_get_member( intval( $_POST['member_id'] ) ); $membership_id = $member['membership_id']; } else { - $member = array(); + $member = []; } $total = 0; @@ -3002,11 +3004,11 @@ function eme_dyndata_member_ajax() { } } } - echo wp_json_encode( array( 'Result' => do_shortcode( $form_html ) ) ); + echo wp_json_encode( [ 'Result' => do_shortcode( $form_html ) ] ); } function eme_get_member_post_answers( $member, $include_dynamicdata = 1 ) { - $answers = array(); + $answers = []; //$fields_seen=array(); $membership_id = $member['membership_id']; @@ -3036,7 +3038,7 @@ function eme_get_member_post_answers( $member, $include_dynamicdata = 1 ) { } else { $value = eme_sanitize_request( $value ); } - $answer = array( + $answer = [ 'field_name' => $formfield['field_name'], 'field_id' => $field_id, 'field_purpose' => $formfield['field_purpose'], @@ -3044,7 +3046,7 @@ function eme_get_member_post_answers( $member, $include_dynamicdata = 1 ) { 'answer' => $value, 'grouping_id' => $group_id, 'occurence_id' => $occurence_id, - ); + ]; $answers[] = $answer; } } @@ -3076,7 +3078,7 @@ function eme_get_member_post_answers( $member, $include_dynamicdata = 1 ) { } else { $value = eme_sanitize_request( $value ); } - $answer = array( + $answer = [ 'field_name' => $formfield['field_name'], 'field_id' => $field_id, 'field_purpose' => $formfield['field_purpose'], @@ -3084,7 +3086,7 @@ function eme_get_member_post_answers( $member, $include_dynamicdata = 1 ) { 'answer' => $value, 'grouping_id' => 0, 'occurence_id' => 0, - ); + ]; $answers[] = $answer; } } @@ -3097,13 +3099,13 @@ function eme_member_answers( $member, $membership, $do_update = 1 ) { } function eme_store_member_answers( $member, $do_update = 1 ) { global $wpdb,$eme_db_prefix; - $fields_seen = array(); + $fields_seen = []; $extra_charge = 0; $membership_id = $member['membership_id']; - $member_answers = array(); - $person_answers = array(); - $all_answers = array(); + $member_answers = []; + $person_answers = []; + $all_answers = []; if ( $do_update ) { $member_id = $member['member_id']; if ( $member_id > 0 ) { @@ -3117,7 +3119,7 @@ function eme_store_member_answers( $member, $do_update = 1 ) { } $person_id = $member['person_id']; - $answer_ids_seen = array(); + $answer_ids_seen = []; $found_answers = eme_get_member_post_answers( $member ); foreach ( $found_answers as $answer ) { if ( $answer['extra_charge'] && is_numeric( $answer['answer'] ) ) { @@ -3466,8 +3468,8 @@ function eme_member_set_paid( $member, $pg = '', $pg_pid = '' ) { return 0; } - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['member_id'] = $member['member_id']; $fields['paid'] = 1; $fields['reminder'] = 0; @@ -3514,8 +3516,8 @@ function eme_member_set_unpaid( $member ) { return true; } - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['member_id'] = $member['member_id']; $fields['paid'] = 0; $fields['payment_date'] = ''; @@ -3546,8 +3548,8 @@ function eme_extend_member( $member, $pg = '', $pg_pid = '' ) { return 0; } $membership = eme_get_membership( $member['membership_id'] ); - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['member_id'] = $member['member_id']; $fields['paid'] = 1; $fields['pg'] = $pg; @@ -3579,8 +3581,8 @@ function eme_renew_expired_member( $member, $pg = '', $pg_pid = '' ) { return 0; } $membership = eme_get_membership( $member['membership_id'] ); - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['member_id'] = $member['member_id']; $fields['paid'] = 1; $fields['pg'] = $pg; @@ -3618,8 +3620,8 @@ function eme_member_set_status( $member_id, $status ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . MEMBERS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['member_id'] = $member_id; $fields['status'] = $status; @@ -3630,8 +3632,8 @@ function eme_stop_member( $member_id, $main_only = 0 ) { global $wpdb,$eme_db_prefix, $eme_timezone; $table = $eme_db_prefix . MEMBERS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['member_id'] = $member_id; if ( $main_only ) { $where['related_member_id'] = 0; @@ -3692,7 +3694,7 @@ function eme_email_member_action( $member, $action ) { $member_body = ''; $contact_subject = ''; $contact_body = ''; - $atts = array(); + $atts = []; if ( $action == 'expiration_reminder' ) { $member_subject = $membership['properties']['reminder_subject_format']; if ( ! eme_is_empty_string( $membership['properties']['reminder_body_text'] ) ) { @@ -3821,12 +3823,12 @@ function eme_email_member_action( $member, $action ) { function eme_add_member_form_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => 0, 'name' => '', - ), - $atts + ], + $atts ) ); if ( ! empty( $name ) ) { @@ -3842,13 +3844,13 @@ function eme_add_member_form_shortcode( $atts ) { function eme_mymemberships_list_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'template_id' => 0, 'template_id_header' => 0, 'template_id_footer' => 0, - ), - $atts + ], + $atts ) ); if ( is_user_logged_in() ) { @@ -3878,16 +3880,16 @@ function eme_members_report_link_shortcode( $atts ) { global $post; eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'group_id' => 0, 'membership_id' => 0, 'template_id' => 0, 'template_id_header' => 0, 'link_text' => __( 'Members CSV', 'events-made-easy' ), 'public_access' => 0, - ), - $atts + ], + $atts ) ); $public_access = filter_var( $public_access, FILTER_VALIDATE_BOOLEAN ); @@ -3916,15 +3918,15 @@ function eme_members_report_link_shortcode( $atts ) { function eme_members_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'group_id' => 0, 'membership_id' => 0, 'template_id' => 0, 'template_id_header' => 0, 'template_id_footer' => 0, - ), - $atts + ], + $atts ) ); @@ -3995,7 +3997,7 @@ function eme_members_frontend_csv_report( $group_id, $membership_id, $template_i foreach ( $member_ids as $member_id ) { $member = eme_get_member( $member_id ); $membership = eme_get_membership( $member['membership_id'] ); - $line = array(); + $line = []; $format_arr = explode( ',', $format ); $line_count = 1; foreach ( $format_arr as $single_format ) { @@ -4011,7 +4013,7 @@ function eme_members_frontend_csv_report( $group_id, $membership_id, $template_i // now we have a line that contains arrays on every position, with $line_count indicating the max size of an arr in the line // so let's use that to output multiple lines for ( $i = 0;$i < $line_count;$i++ ) { - $output = array(); + $output = []; foreach ( $line as $el_arr ) { if ( isset( $el_arr[ $i ] ) ) { $output[] = $el_arr[ $i ]; @@ -4041,17 +4043,17 @@ function eme_access_meta_box_cb( $post ) { if ( eme_is_serialized( $selected_membershipids ) ) { $selected_membershipids_arr = eme_unserialize( $selected_membershipids ); } else { - $selected_membershipids_arr = array( $selected_membershipids ); + $selected_membershipids_arr = [ $selected_membershipids ]; } if ( eme_is_serialized( $selected_groupids ) ) { $selected_groupids_arr = eme_unserialize( $selected_groupids ); } else { - $selected_groupids_arr = array( $selected_groupids ); + $selected_groupids_arr = [ $selected_groupids ]; } $all_memberships = eme_get_memberships(); $all_groups = eme_get_static_groups(); echo "
    '; - $memberships_arr = array(); + $memberships_arr = []; foreach ( $all_memberships as $membership ) { $memberships_arr[ $membership['membership_id'] ] = $membership['name']; } @@ -4060,7 +4062,7 @@ function eme_access_meta_box_cb( $post ) { echo ""; echo '

    '; echo "
    '; - $groups_arr = array(); + $groups_arr = []; foreach ( $all_groups as $group ) { $groups_arr[ $group['group_id'] ] = $group['name']; } @@ -4124,10 +4126,10 @@ function eme_add_member_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $form_html = __( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -4136,10 +4138,10 @@ function eme_add_member_ajax() { if ( ! isset( $_POST['eme_frontend_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) { $form_html = __( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -4147,10 +4149,10 @@ function eme_add_member_ajax() { if ( ! isset( $_POST['membership_id'] ) ) { $form_html = __( 'No membership selected', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } else { @@ -4163,10 +4165,10 @@ function eme_add_member_ajax() { if ( ! $captcha_res ) { $result = __( 'Please check the hCaptcha box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $result, - ) + ] ); wp_die(); } @@ -4175,10 +4177,10 @@ function eme_add_member_ajax() { if ( ! $captcha_res ) { $result = __( 'Please check the Google reCAPTCHA box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $result, - ) + ] ); wp_die(); } @@ -4187,10 +4189,10 @@ function eme_add_member_ajax() { if ( ! $captcha_res ) { $result = __( 'You entered an incorrect code', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $result, - ) + ] ); wp_die(); } @@ -4204,10 +4206,10 @@ function eme_add_member_ajax() { if ( ! $tmp_member['discount'] || empty( $dcodes_used ) || count( $dcodes_used ) != count( $dcodes_entered ) ) { $result = __( 'You did not enter a valid discount code', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $result, - ) + ] ); wp_die(); } @@ -4216,10 +4218,10 @@ function eme_add_member_ajax() { if ( has_filter( 'eme_eval_member_form_post_filter' ) ) { $eval_filter_return = apply_filters( 'eme_eval_member_form_post_filter', $membership ); } else { - $eval_filter_return = array( + $eval_filter_return = [ 0 => 1, 1 => '', - ); + ]; } if ( is_array( $eval_filter_return ) && ! $eval_filter_return[0] ) { @@ -4246,11 +4248,11 @@ function eme_add_member_ajax() { if ( $pg_count == 1 && get_option( 'eme_pg_submit_immediately' ) ) { $payment_form = eme_payment_member_form( $payment_id ); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $form_result_message, 'paymentform' => $payment_form, - ) + ] ); } elseif ( get_option( 'eme_payment_redirect' ) ) { $payment = eme_get_payment( $payment_id ); @@ -4262,30 +4264,30 @@ function eme_add_member_ajax() { $form_result_message .= '
    ' . $redirect_msg; } echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $form_result_message, 'waitperiod' => $waitperiod, 'paymentredirect' => $payment_url, - ) + ] ); } else { $payment_form = eme_payment_member_form( $payment_id ); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $form_result_message, 'paymentform' => $payment_form, - ) + ] ); } } else { // price=0 echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $form_result_message, - ) + ] ); } } elseif ( $payment_id ) { @@ -4293,18 +4295,18 @@ function eme_add_member_ajax() { eme_captcha_remove( $captcha_res ); } echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $form_result_message, - ) + ] ); } else { // failed echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_result_message, - ) + ] ); } wp_die(); @@ -4323,10 +4325,10 @@ function eme_replace_member_placeholders( $format, $membership, $member, $target if ( $member['person_id'] == -1 ) { // -1 ? then this is from a fake member $person = eme_add_update_person_from_form( 0, '', '', '', 0, 0, 1 ); - $person_answers = array(); + $person_answers = []; $member_answers = eme_get_member_post_answers( $member, 0 ); // add the 0-option to exclude dynamic answers - $dyn_answers = array(); - $files = array(); + $dyn_answers = []; + $files = []; } else { $person = eme_get_person( $member['person_id'] ); $person_answers = eme_get_person_answers( $member['person_id'] ); @@ -4335,7 +4337,7 @@ function eme_replace_member_placeholders( $format, $membership, $member, $target } else { $member_answers = eme_get_nodyndata_member_answers( $member['member_id'] ); } - $dyn_answers = ( isset( $membership['properties']['dyndata'] ) ) ? eme_get_dyndata_member_answers( $member['member_id'] ) : array(); + $dyn_answers = ( isset( $membership['properties']['dyndata'] ) ) ? eme_get_dyndata_member_answers( $member['member_id'] ) : []; $files = eme_get_uploaded_files( $member['member_id'], 'members' ); } $answers = array_merge( $member_answers, $person_answers ); @@ -4381,7 +4383,7 @@ function eme_replace_member_placeholders( $format, $membership, $member, $target } elseif ( preg_match( '/#_APPLIEDDISCOUNTNAMES$/', $result ) ) { if ( ! empty( $member['discountids'] ) ) { $discount_ids = explode( ',', $member['discountids'] ); - $discount_names = array(); + $discount_names = []; foreach ( $discount_ids as $discount_id ) { $discount = eme_get_discount( $discount_id ); if ( $discount && isset( $discount['name'] ) ) { @@ -4683,9 +4685,9 @@ function eme_replace_member_placeholders( $format, $membership, $member, $target $targetBasePath = EME_UPLOAD_DIR . '/members/' . $member['member_id']; $targetBaseUrl = EME_UPLOAD_URL . '/members/' . $member['member_id']; $url_to_encode = eme_member_url( $member ); - list($target_file,$target_url) = eme_generate_qrcode( $url_to_encode, $targetBasePath, $targetBaseUrl, $size ); + [$target_file, $target_url] = eme_generate_qrcode( $url_to_encode, $targetBasePath, $targetBaseUrl, $size ); if ( is_file( $target_file ) ) { - list($width, $height, $type, $attr) = getimagesize( $target_file ); + [$width, $height, $type, $attr] = getimagesize( $target_file ); $replacement = ""; } } elseif ( preg_match( '/#_DYNAMICFIELD\{(.+?)\}$/', $result, $matches ) ) { @@ -4749,7 +4751,7 @@ function eme_replace_member_placeholders( $format, $membership, $member, $target } } } elseif ( preg_match( '/#_FILES/', $result ) ) { - $res_files = array(); + $res_files = []; foreach ( $files as $file ) { if ( $target == 'html' ) { $res_files[] = eme_get_uploaded_file_html( $file ); @@ -4763,7 +4765,7 @@ function eme_replace_member_placeholders( $format, $membership, $member, $target $replacement = join( "\n", $res_files ); } } elseif ( preg_match( '/#_PERSONAL_FILES/', $result ) ) { - $res_files = array(); + $res_files = []; $person_files = eme_get_uploaded_files( $member['person_id'], 'people' ); foreach ( $person_files as $file ) { if ( $target == 'html' ) { @@ -4800,7 +4802,7 @@ function eme_replace_member_placeholders( $format, $membership, $member, $target $sep = '||'; } $formfield = eme_get_formfield( $field_key ); - if ( ! empty( $formfield ) && in_array( $formfield['field_purpose'], array( 'generic', 'members' ) ) ) { + if ( ! empty( $formfield ) && in_array( $formfield['field_purpose'], [ 'generic', 'members' ] ) ) { $field_id = $formfield['field_id']; $field_replace = ''; foreach ( $answers as $answer ) { @@ -4867,7 +4869,7 @@ function eme_replace_membership_placeholders( $format, $membership, $target = 'h if ( ! empty( $membership ) && isset( $membership['membership_id'] ) ) { $answers = eme_get_membership_answers( $membership['membership_id'] ); } else { - $answers = array(); + $answers = []; } // replace what we can inside curly brackets @@ -5103,7 +5105,7 @@ function eme_import_csv_members() { return __( 'Access denied', 'events-made-easy' ); } //validate whether uploaded file is a csv file - $csvMimes = array( 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ); + $csvMimes = [ 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ]; if ( empty( $_FILES['eme_csv']['name'] ) || ! in_array( $_FILES['eme_csv']['type'], $csvMimes ) ) { return sprintf( __( 'No CSV file detected: %s', 'events-made-easy' ), $_FILES['eme_csv']['type'] ); } @@ -5274,7 +5276,7 @@ function eme_import_csv_member_dynamic_answers() { } //validate whether uploaded file is a csv file - $csvMimes = array( 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ); + $csvMimes = [ 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ]; if ( empty( $_FILES['eme_csv']['name'] ) || ! in_array( $_FILES['eme_csv']['type'], $csvMimes ) ) { return sprintf( __( 'No CSV file detected: %s', 'events-made-easy' ), $_FILES['eme_csv']['type'] ); } @@ -5316,7 +5318,7 @@ function eme_import_csv_member_dynamic_answers() { } else { // now loop over the rest // a simple array to be able to increase occurence counter based on memberid and grouping - $occurences = array(); + $occurences = []; while ( ( $row = fgetcsv( $handle, 0, $delimiter, $enclosure ) ) !== false ) { $line = array_combine( $headers, $row ); // remove columns with empty values @@ -5344,7 +5346,7 @@ function eme_import_csv_member_dynamic_answers() { $member_id = eme_is_member( $person_id, $membership['membership_id'] ); if ( $member_id ) { if ( ! isset( $occurences[ $member_id ] ) ) { - $occurences[ $member_id ] = array(); + $occurences[ $member_id ] = []; } // make sure grouping contains a sensible value (we call it "index now, but keep "grouping" for backwards compat) if ( isset( $line['index'] ) ) { @@ -5414,7 +5416,7 @@ function eme_member_person_autocomplete_ajax( $no_wp_die = 0 ) { if ( ! current_user_can( get_option( 'eme_cap_list_members' ) ) ) { wp_die(); } - $return = array(); + $return = []; $q = ''; if ( isset( $_REQUEST['lastname'] ) ) { $q = strtolower( eme_sanitize_request( $_REQUEST['lastname'] ) ); @@ -5466,7 +5468,7 @@ function eme_member_person_autocomplete_ajax( $no_wp_die = 0 ) { $persons = $wpdb->get_results( $sql, ARRAY_A ); foreach ( $persons as $item ) { - $record = array(); + $record = []; $record['lastname'] = eme_esc_html( $item['lastname'] ); $record['firstname'] = eme_esc_html( $item['firstname'] ); $record['email'] = eme_esc_html( $item['email'] ); @@ -5485,7 +5487,7 @@ function eme_member_main_account_autocomplete_ajax() { if ( ! current_user_can( get_option( 'eme_cap_list_members' ) ) ) { wp_die(); } - $return = array(); + $return = []; $q = ''; $membership_id = 0; $member_id = 0; @@ -5508,7 +5510,7 @@ function eme_member_main_account_autocomplete_ajax() { $search = "(lastname LIKE '%" . esc_sql( $wpdb->esc_like( $q ) ) . "%' OR firstname LIKE '%" . esc_sql( $wpdb->esc_like( $q ) ) . "%') AND members.member_id <> $member_id AND members.related_member_id=0 AND members.membership_id=$membership_id"; $persons = eme_get_members( '', $search ); foreach ( $persons as $item ) { - $record = array(); + $record = []; $record['lastname'] = eme_esc_html( $item['lastname'] ); $record['firstname'] = eme_esc_html( $item['firstname'] ); $record['email'] = eme_esc_html( $item['email'] ); @@ -5542,7 +5544,7 @@ function eme_ajax_memberships_list() { $status_grace = EME_MEMBER_STATUS_GRACE; $table = $eme_db_prefix . MEMBERSHIPS_TBNAME; $members_table = $eme_db_prefix . MEMBERS_TBNAME; - $ajaxResult = array(); + $ajaxResult = []; $formfields = eme_get_formfields( '', 'memberships' ); @@ -5552,22 +5554,22 @@ function eme_ajax_memberships_list() { $pagesize = ( isset( $_REQUEST['jtPageSize'] ) ) ? intval( $_REQUEST['jtPageSize'] ) : 10; $sorting = ( ! empty( $_REQUEST['jtSorting'] ) && ! empty( eme_sanitize_sql_orderby( $_REQUEST['jtSorting'] ) ) ) ? 'ORDER BY ' . esc_sql( eme_sanitize_sql_orderby($_REQUEST['jtSorting']) ) : ''; - $sql = $wpdb->prepare("SELECT membership_id,COUNT(*) AS familymembercount FROM $members_table WHERE status IN (%d,%d) AND related_member_id>0 GROUP BY membership_id",$status_active,$status_grace); + $sql = $wpdb->prepare("SELECT membership_id,COUNT(*) AS familymembercount FROM $members_table WHERE status IN (%d,%d) AND related_member_id>0 GROUP BY membership_id", $status_active, $status_grace); $res = $wpdb->get_results( $sql, ARRAY_A ); - $familymembercount = array(); + $familymembercount = []; foreach ( $res as $val ) { $familymembercount[ $val['membership_id'] ] = $val['familymembercount']; } - $sql = $wpdb->prepare("SELECT membership_id,COUNT(*) AS mainmembercount FROM $members_table WHERE status IN (%d,%d) AND related_member_id=0 GROUP BY membership_id",$status_active,$status_grace); + $sql = $wpdb->prepare("SELECT membership_id,COUNT(*) AS mainmembercount FROM $members_table WHERE status IN (%d,%d) AND related_member_id=0 GROUP BY membership_id", $status_active, $status_grace); $res = $wpdb->get_results( $sql, ARRAY_A ); - $mainmembercount = array(); + $mainmembercount = []; foreach ( $res as $val ) { $mainmembercount[ $val['membership_id'] ] = $val['mainmembercount']; } $sql = "SELECT * FROM $table $sorting LIMIT $start,$pagesize"; $rows = $wpdb->get_results( $sql, ARRAY_A ); - $records = array(); + $records = []; foreach ( $rows as $item ) { if ( empty( $item['name'] ) ) { $item['name'] = __( 'No name', 'events-made-easy' ); @@ -5577,7 +5579,7 @@ function eme_ajax_memberships_list() { $contact_email = $contact->user_email; $contact_name = $contact->display_name; - $record = array(); + $record = []; $record['membership_id'] = $item['membership_id']; if ( current_user_can( get_option( 'eme_cap_edit_members' ) ) ) { $record['name'] = "" . eme_esc_html( $item['name'] ) . ''; @@ -5627,7 +5629,7 @@ function eme_ajax_members_list( $dynamic_groupname = '' ) { global $wpdb,$eme_db_prefix,$eme_timezone; check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); $eme_member_status_array = eme_member_status_array(); - $ajaxResult = array(); + $ajaxResult = []; if ( ! current_user_can( get_option( 'eme_cap_list_members' ) ) ) { $ajaxResult['Result'] = 'Error'; @@ -5640,9 +5642,9 @@ function eme_ajax_members_list( $dynamic_groupname = '' ) { $table = $eme_db_prefix . GROUPS_TBNAME; $group['type'] = 'dynamic_members'; $group['name'] = $dynamic_groupname . ' ' . __( '(Dynamic)', 'events-made-easy' ); - $search_terms = array(); + $search_terms = []; // the same as in add_update_group - $search_fields = array( 'search_membershipids', 'search_memberstatus', 'search_person', 'search_groups', 'search_memberid', 'search_customfields', 'search_customfieldids' ); + $search_fields = [ 'search_membershipids', 'search_memberstatus', 'search_person', 'search_groups', 'search_memberid', 'search_customfields', 'search_customfieldids' ]; foreach ( $search_fields as $search_field ) { if ( isset( $_POST[ $search_field ] ) ) { $search_terms[ $search_field ] = esc_sql( eme_sanitize_request( $_POST[ $search_field ] ) ); @@ -5666,9 +5668,9 @@ function eme_ajax_members_list( $dynamic_groupname = '' ) { } else { $formfields = eme_get_formfields( '', 'members,generic' ); } - $records = array(); + $records = []; foreach ( $rows as $item ) { - $record = array(); + $record = []; $membership = eme_get_membership( $item['membership_id'] ); // we can sort on member_id, but in our constructed sql , we have members.member_id and ans.member_id // some mysql databases don't like it if you then just sort on member_id, so we'll change it to members.member_id @@ -5781,7 +5783,7 @@ function eme_ajax_members_select2() { check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); if ( ! current_user_can( get_option( 'eme_cap_list_members' ) ) ) { - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'Error'; $ajaxResult['htmlmessage'] = __( 'Access denied!', 'events-made-easy' ); print wp_json_encode( $ajaxResult ); @@ -5792,7 +5794,7 @@ function eme_ajax_members_select2() { $people_table = $eme_db_prefix . PEOPLE_TBNAME; $members_table = $eme_db_prefix . MEMBERS_TBNAME; $memberships_table = $eme_db_prefix . MEMBERSHIPS_TBNAME; - $jTableResult = array(); + $jTableResult = []; $q = isset( $_REQUEST['q'] ) ? strtolower( eme_sanitize_request( $_REQUEST['q'] ) ) : ''; if ( ! empty( $q ) ) { $where = "(people.lastname LIKE '%" . esc_sql( $wpdb->esc_like( $q ) ) . "%' OR people.firstname LIKE '%" . esc_sql( $wpdb->esc_like( $q ) ) . "%')"; @@ -5813,11 +5815,11 @@ function eme_ajax_members_select2() { LEFT JOIN $people_table as people ON members.person_id=people.person_id WHERE $where"; - $records = array(); + $records = []; $recordCount = $wpdb->get_var( $count_sql ); $members = $wpdb->get_results( $sql, ARRAY_A ); foreach ( $members as $member ) { - $record = array(); + $record = []; $record['id'] = $member['member_id']; // no eme_esc_html here, select2 does it own escaping upon arrival $record['text'] = eme_format_full_name( $member['firstname'], $member['lastname'] ) . ' (' . $member['membership_name'] . ')'; @@ -5888,7 +5890,7 @@ function eme_ajax_manage_members() { if ( $template_id_subject && $template_id ) { eme_ajax_action_send_member_mails( $ids_arr, $template_id_subject, $template_id ); } else { - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['htmlmessage'] = "

    " . esc_html__( 'Content of subject or body was empty, no mail has been sent.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'ERROR'; print wp_json_encode( $ajaxResult ); @@ -5917,7 +5919,7 @@ function eme_ajax_manage_members() { } function eme_ajax_manage_memberships() { - $ajaxResult = array(); + $ajaxResult = []; check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); if ( isset( $_REQUEST['do_action'] ) ) { $do_action = eme_sanitize_request( $_REQUEST['do_action'] ); @@ -5949,7 +5951,7 @@ function eme_ajax_action_send_member_mails( $ids_arr, $subject_template_id, $bod $mail_text_html = get_option( 'eme_rsvp_send_html' ) ? 'html' : 'text'; $subject = eme_get_template_format_plain( $subject_template_id ); $body = eme_get_template_format_plain( $body_template_id ); - $ajaxResult = array(); + $ajaxResult = []; if ( eme_is_empty_string( $subject ) || eme_is_empty_string( $body ) ) { $ajaxResult['htmlmessage'] = "

    " . esc_html__( 'Content of subject or body was empty, no mail has been sent.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'ERROR'; @@ -5973,7 +5975,7 @@ function eme_ajax_action_send_member_mails( $ids_arr, $subject_template_id, $bod } } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mail_ok ) { $ajaxResult['htmlmessage'] = "

    " . esc_html__( 'The mail has been sent.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -5997,7 +5999,7 @@ function eme_ajax_action_delete_members( $ids_arr, $trash_person = 0 ) { print wp_json_encode( $ajaxResult ); } } else { - $ajaxResult = array(); + $ajaxResult = []; foreach ( $ids_arr as $member_id ) { eme_delete_member( $member_id ); } @@ -6026,7 +6028,7 @@ function eme_ajax_action_set_member_unpaid( $ids_arr, $action, $send_mail ) { $action_ok = 0; } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mails_ok && $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . esc_html__( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -6052,7 +6054,7 @@ function eme_ajax_action_resend_paid_member( $ids_arr, $action ) { } } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mails_ok ) { $ajaxResult['htmlmessage'] = "

    " . esc_html__( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -6117,7 +6119,7 @@ function eme_ajax_action_payment_membership( $ids_arr, $send_mail ) { eme_mark_payment_paid( $member['payment_id'], 0 ); } - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['htmlmessage'] = "

    " . esc_html__( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; print wp_json_encode( $ajaxResult ); @@ -6147,7 +6149,7 @@ function eme_ajax_action_stop_membership( $ids_arr, $action, $send_mail ) { $action_ok = 0; } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mails_ok && $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . esc_html__( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -6172,7 +6174,7 @@ function eme_ajax_action_resend_pending_member( $ids_arr, $action ) { } } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mails_ok ) { $ajaxResult['htmlmessage'] = "

    " . esc_html__( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -6191,7 +6193,7 @@ function eme_ajax_action_resend_member_reminders( $ids_arr ) { eme_member_send_expiration_reminder( $member_id ); } } - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['htmlmessage'] = "

    " . esc_html__( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; print wp_json_encode( $ajaxResult ); @@ -6214,7 +6216,7 @@ function eme_generate_member_pdf( $member, $membership, $template_id ) { $orientation = $template['properties']['pdf_orientation']; $pagesize = $template['properties']['pdf_size']; if ( $pagesize == 'custom' ) { - $pagesize = array( 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ); + $pagesize = [ 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ]; } $dompdf->setPaper( $pagesize, $orientation ); @@ -6279,7 +6281,7 @@ function eme_ajax_generate_member_pdf( $ids_arr, $template_id, $template_id_head $orientation = $template['properties']['pdf_orientation']; $pagesize = $template['properties']['pdf_size']; if ( $pagesize == 'custom' ) { - $pagesize = array( 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ); + $pagesize = [ 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ]; } $dompdf->setPaper( $pagesize, $orientation ); @@ -6341,7 +6343,7 @@ function eme_ajax_generate_member_html( $ids_arr, $template_id, $template_id_hea } function eme_get_membership_post_answers() { - $answers = array(); + $answers = []; foreach ( $_POST as $key => $value ) { if ( preg_match( '/^FIELD(\d+)$/', $key, $matches ) ) { $field_id = intval( $matches[1] ); @@ -6354,12 +6356,12 @@ function eme_get_membership_post_answers() { if ( is_array( $value ) ) { $value = eme_convert_array2multi( $value ); } - $answer = array( + $answer = [ 'field_name' => $formfield['field_name'], 'field_id' => $field_id, 'extra_charge' => $formfield['extra_charge'], 'answer' => $value, - ); + ]; $answers[] = $answer; } } @@ -6380,7 +6382,7 @@ function eme_get_membership_answers( $membership_id ) { } function eme_membership_store_answers( $membership_id ) { - $answer_ids_seen = array(); + $answer_ids_seen = []; $all_answers = eme_get_membership_answers( $membership_id ); $found_answers = eme_get_membership_post_answers(); @@ -6409,7 +6411,7 @@ function eme_membership_store_answers( $membership_id ) { function eme_get_cf_membership_ids( $val, $field_id, $is_multi = 0 ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . ANSWERS_TBNAME; - $conditions = array(); + $conditions = []; $val = eme_kses( $val ); if ( is_array( $val ) ) { diff --git a/eme-options.php b/eme-options.php index 3a616a50..2da8af78 100644 --- a/eme-options.php +++ b/eme-options.php @@ -108,7 +108,7 @@ function eme_add_options( $reset = 0 ) { $eme_bd_email_subject_localizable = __( 'Happy birthday #_PERSONFIRSTNAME', 'events-made-easy' ); $eme_bd_email_body_localizable = __( 'Hi #_PERSONFIRSTNAME,

    Congratulations on your birthday!!!

    From EME', 'events-made-easy' ); - $eme_options = array( + $eme_options = [ 'eme_event_list_item_format' => '
  • #_STARTDATE - #_STARTTIME
    #_LINKEDNAME
    #_TOWN
  • ', 'eme_event_list_item_format_header' => DEFAULT_EVENT_LIST_HEADER_FORMAT, 'eme_cat_event_list_item_format_header' => DEFAULT_CAT_EVENT_LIST_HEADER_FORMAT, @@ -552,7 +552,7 @@ function eme_add_options( $reset = 0 ) { 'eme_check_free_waiting' => 0, 'eme_unique_email_per_person' => 0, 'eme_multisite_active' => 0, - ); + ]; foreach ( $eme_options as $key => $value ) { eme_add_option( $key, $value, $reset ); @@ -581,17 +581,17 @@ function eme_update_options( $db_version ) { } if ( $db_version < 119 ) { // remove some deprecated options - $options = array( 'eme_image_max_width', 'eme_image_max_height', 'eme_image_max_size', 'eme_legacy', 'eme_deprecated', 'eme_legacy_warning', 'eme_list_events_page', 'eme_deny_mail_event_edit', 'eme_fb_app_id' ); + $options = [ 'eme_image_max_width', 'eme_image_max_height', 'eme_image_max_size', 'eme_legacy', 'eme_deprecated', 'eme_legacy_warning', 'eme_list_events_page', 'eme_deny_mail_event_edit', 'eme_fb_app_id' ]; foreach ( $options as $opt ) { delete_option( $opt ); } // rename some options - $options2 = array( + $options2 = [ 'eme_cron_reminder_unpayed_minutes' => 'eme_cron_reminder_unpaid_minutes', 'eme_cron_cleanup_unpayed_minutes' => 'eme_cron_cleanup_unpaid_minutes', 'eme_cron_reminder_unpayed_subject' => 'eme_cron_reminder_unpaid_subject', 'eme_cron_reminder_unpayed_body' => 'eme_cron_reminder_unpaid_body', - ); + ]; foreach ( $options2 as $old_option => $new_option ) { if ( get_option( $old_option ) ) { update_option( $new_option, get_option( $old_option ) ); @@ -617,9 +617,9 @@ function eme_update_options( $db_version ) { } if ( $db_version < 197 ) { // rename some options - $options2 = array( + $options2 = [ 'eme_rsvp_required_field_string' => 'eme_form_required_field_string', - ); + ]; foreach ( $options2 as $old_option => $new_option ) { if ( get_option( $old_option ) ) { update_option( $new_option, get_option( $old_option ) ); @@ -629,10 +629,10 @@ function eme_update_options( $db_version ) { } if ( $db_version < 206 ) { delete_option( 'eme_gmap_api_key' ); - $options2 = array( + $options2 = [ 'eme_gmap_active' => 'eme_map_active', 'eme_gmap_zooming' => 'eme_map_zooming', - ); + ]; foreach ( $options2 as $old_option => $new_option ) { if ( get_option( $old_option ) ) { update_option( $new_option, get_option( $old_option ) ); @@ -675,10 +675,10 @@ function eme_update_options( $db_version ) { } if ( $db_version < 247 ) { // rename some options - $options2 = array( + $options2 = [ 'eme_registration_denied_email_subject' => 'eme_registration_trashed_email_subject', 'eme_registration_denied_email_body' => 'eme_registration_trashed_email_body', - ); + ]; foreach ( $options2 as $old_option => $new_option ) { if ( get_option( $old_option ) ) { update_option( $new_option, get_option( $old_option ) ); @@ -688,10 +688,10 @@ function eme_update_options( $db_version ) { } if ( $db_version < 250 ) { // rename some options - $options2 = array( + $options2 = [ 'eme_cap_people' => 'eme_cap_edit_people', 'eme_cap_members' => 'eme_cap_edit_members', - ); + ]; foreach ( $options2 as $old_option => $new_option ) { if ( get_option( $old_option ) ) { update_option( $new_option, get_option( $old_option ) ); @@ -707,9 +707,9 @@ function eme_update_options( $db_version ) { } if ( $db_version < 298 ) { // rename some options - $options2 = array( + $options2 = [ 'eme_captcha_for_booking' => 'eme_captcha_for_forms', - ); + ]; foreach ( $options2 as $old_option => $new_option ) { if ( get_option( $old_option ) ) { update_option( $new_option, get_option( $old_option ) ); @@ -732,9 +732,9 @@ function eme_update_options( $db_version ) { } if ( $db_version < 306 ) { // rename some options - $options2 = array( + $options2 = [ 'eme_mail_recipient_format' => 'eme_full_name_format', - ); + ]; foreach ( $options2 as $old_option => $new_option ) { if ( get_option( $old_option ) ) { update_option( $new_option, get_option( $old_option ) ); @@ -749,9 +749,9 @@ function eme_update_options( $db_version ) { } if ( $db_version < 315 ) { // rename some options - $options2 = array( + $options2 = [ 'eme_gdpr_remove_old_bookings_days' => 'eme_gdpr_anonymize_old_bookings_days', - ); + ]; foreach ( $options2 as $old_option => $new_option ) { if ( get_option( $old_option ) ) { update_option( $new_option, get_option( $old_option ) ); @@ -838,9 +838,9 @@ function eme_options_delete() { function eme_metabox_options_delete() { global $wpdb,$eme_db_prefix; - $screens = array( 'events_page_eme-new_event', 'toplevel_page_eme-manager' ); + $screens = [ 'events_page_eme-new_event', 'toplevel_page_eme-manager' ]; foreach ( $screens as $screen ) { - foreach ( array( 'metaboxhidden', 'closedpostboxes', 'wp_metaboxorder', 'meta-box-order', 'screen_layout' ) as $option ) { + foreach ( [ 'metaboxhidden', 'closedpostboxes', 'wp_metaboxorder', 'meta-box-order', 'screen_layout' ] as $option ) { $keys[] = "'{$option}_{$screen}'"; } } @@ -984,56 +984,56 @@ function eme_options_register() { if ( ! isset( $_POST['option_page'] ) || ( $_POST['option_page'] != 'eme-options' ) ) { return; } - $options = array(); + $options = []; $tab = isset( $_POST['tab'] ) ? eme_sanitize_request( $_POST['tab'] ) : 'general'; switch ( $tab ) { case 'general': - $options = array( 'eme_use_select_for_locations', 'eme_add_events_locs_link_search', 'eme_rsvp_enabled', 'eme_tasks_enabled', 'eme_categories_enabled', 'eme_attributes_enabled', 'eme_map_is_active', 'eme_load_js_in_header', 'eme_use_client_clock', 'eme_uninstall_drop_data', 'eme_uninstall_drop_settings', 'eme_shortcodes_in_widgets', 'eme_enable_notes_placeholders', 'eme_autocomplete_sources', 'eme_captcha_for_forms', 'eme_recaptcha_for_forms', 'eme_recaptcha_site_key', 'eme_recaptcha_secret_key', 'eme_hcaptcha_for_forms', 'eme_hcaptcha_site_key', 'eme_hcaptcha_secret_key', 'eme_honeypot_for_forms', 'eme_frontend_nocache', 'eme_use_is_page_for_title' ); + $options = [ 'eme_use_select_for_locations', 'eme_add_events_locs_link_search', 'eme_rsvp_enabled', 'eme_tasks_enabled', 'eme_categories_enabled', 'eme_attributes_enabled', 'eme_map_is_active', 'eme_load_js_in_header', 'eme_use_client_clock', 'eme_uninstall_drop_data', 'eme_uninstall_drop_settings', 'eme_shortcodes_in_widgets', 'eme_enable_notes_placeholders', 'eme_autocomplete_sources', 'eme_captcha_for_forms', 'eme_recaptcha_for_forms', 'eme_recaptcha_site_key', 'eme_recaptcha_secret_key', 'eme_hcaptcha_for_forms', 'eme_hcaptcha_site_key', 'eme_hcaptcha_secret_key', 'eme_honeypot_for_forms', 'eme_frontend_nocache', 'eme_use_is_page_for_title' ]; break; case 'seo': - $options = array( 'eme_seo_permalink', 'eme_permalink_events_prefix', 'eme_permalink_locations_prefix', 'eme_permalink_categories_prefix', 'eme_permalink_calendar_prefix', 'eme_permalink_payments_prefix' ); + $options = [ 'eme_seo_permalink', 'eme_permalink_events_prefix', 'eme_permalink_locations_prefix', 'eme_permalink_categories_prefix', 'eme_permalink_calendar_prefix', 'eme_permalink_payments_prefix' ]; break; case 'access': - $options = array( 'eme_cap_add_event', 'eme_cap_author_event', 'eme_cap_publish_event', 'eme_cap_list_events', 'eme_cap_edit_events', 'eme_cap_manage_task_signups', 'eme_cap_list_locations', 'eme_cap_add_locations', 'eme_cap_author_locations', 'eme_cap_edit_locations', 'eme_cap_categories', 'eme_cap_holidays', 'eme_cap_templates', 'eme_cap_access_people', 'eme_cap_list_people', 'eme_cap_edit_people', 'eme_cap_author_person', 'eme_cap_access_members', 'eme_cap_list_members', 'eme_cap_edit_members', 'eme_cap_author_member', 'eme_cap_discounts', 'eme_cap_list_approve', 'eme_cap_author_approve', 'eme_cap_approve', 'eme_cap_list_registrations', 'eme_cap_author_registrations', 'eme_cap_registrations', 'eme_cap_attendancecheck', 'eme_cap_membercheck', 'eme_cap_forms', 'eme_cap_cleanup', 'eme_cap_settings', 'eme_cap_send_mails', 'eme_cap_send_other_mails', 'eme_cap_list_attendances', 'eme_cap_manage_attendances' ); + $options = [ 'eme_cap_add_event', 'eme_cap_author_event', 'eme_cap_publish_event', 'eme_cap_list_events', 'eme_cap_edit_events', 'eme_cap_manage_task_signups', 'eme_cap_list_locations', 'eme_cap_add_locations', 'eme_cap_author_locations', 'eme_cap_edit_locations', 'eme_cap_categories', 'eme_cap_holidays', 'eme_cap_templates', 'eme_cap_access_people', 'eme_cap_list_people', 'eme_cap_edit_people', 'eme_cap_author_person', 'eme_cap_access_members', 'eme_cap_list_members', 'eme_cap_edit_members', 'eme_cap_author_member', 'eme_cap_discounts', 'eme_cap_list_approve', 'eme_cap_author_approve', 'eme_cap_approve', 'eme_cap_list_registrations', 'eme_cap_author_registrations', 'eme_cap_registrations', 'eme_cap_attendancecheck', 'eme_cap_membercheck', 'eme_cap_forms', 'eme_cap_cleanup', 'eme_cap_settings', 'eme_cap_send_mails', 'eme_cap_send_other_mails', 'eme_cap_list_attendances', 'eme_cap_manage_attendances' ]; break; case 'events': - $options = array( 'eme_events_page', 'eme_display_events_in_events_page', 'eme_display_calendar_in_events_page', 'eme_event_list_number_items', 'eme_event_initial_state', 'eme_event_list_item_format_header', 'eme_cat_event_list_item_format_header', 'eme_event_list_item_format', 'eme_event_list_item_format_footer', 'eme_cat_event_list_item_format_footer', 'eme_event_page_title_format', 'eme_event_html_title_format', 'eme_single_event_format', 'eme_show_period_monthly_dateformat', 'eme_show_period_yearly_dateformat', 'eme_events_page_title', 'eme_no_events_message', 'eme_filter_form_format', 'eme_redir_priv_event_url' ); + $options = [ 'eme_events_page', 'eme_display_events_in_events_page', 'eme_display_calendar_in_events_page', 'eme_event_list_number_items', 'eme_event_initial_state', 'eme_event_list_item_format_header', 'eme_cat_event_list_item_format_header', 'eme_event_list_item_format', 'eme_event_list_item_format_footer', 'eme_cat_event_list_item_format_footer', 'eme_event_page_title_format', 'eme_event_html_title_format', 'eme_single_event_format', 'eme_show_period_monthly_dateformat', 'eme_show_period_yearly_dateformat', 'eme_events_page_title', 'eme_no_events_message', 'eme_filter_form_format', 'eme_redir_priv_event_url' ]; break; case 'calendar': - $options = array( 'eme_small_calendar_event_title_format', 'eme_small_calendar_event_title_separator', 'eme_full_calendar_event_format', 'eme_cal_hide_past_events', 'eme_cal_show_single' ); + $options = [ 'eme_small_calendar_event_title_format', 'eme_small_calendar_event_title_separator', 'eme_full_calendar_event_format', 'eme_cal_hide_past_events', 'eme_cal_show_single' ]; break; case 'locations': - $options = array( 'eme_location_list_format_header', 'eme_location_list_format_item', 'eme_location_list_format_footer', 'eme_location_page_title_format', 'eme_location_html_title_format', 'eme_single_location_format', 'eme_location_event_list_item_format', 'eme_location_no_events_message' ); + $options = [ 'eme_location_list_format_header', 'eme_location_list_format_item', 'eme_location_list_format_footer', 'eme_location_page_title_format', 'eme_location_html_title_format', 'eme_single_location_format', 'eme_location_event_list_item_format', 'eme_location_no_events_message' ]; break; case 'members': - $options = array( 'eme_page_access_denied', 'eme_membership_login_required_string', 'eme_redir_protected_pages_url', 'eme_membership_attendance_msg', 'eme_membership_unauth_attendance_msg', 'eme_members_show_people_info' ); + $options = [ 'eme_page_access_denied', 'eme_membership_login_required_string', 'eme_redir_protected_pages_url', 'eme_membership_attendance_msg', 'eme_membership_unauth_attendance_msg', 'eme_members_show_people_info' ]; break; case 'rss': - $options = array( 'eme_rss_main_title', 'eme_rss_main_description', 'eme_rss_title_format', 'eme_rss_description_format', 'eme_rss_show_pubdate', 'eme_rss_pubdate_startdate', 'eme_ical_description_format', 'eme_ical_location_format', 'eme_ical_title_format', 'eme_ical_quote_tzid' ); + $options = [ 'eme_rss_main_title', 'eme_rss_main_description', 'eme_rss_title_format', 'eme_rss_description_format', 'eme_rss_show_pubdate', 'eme_rss_pubdate_startdate', 'eme_ical_description_format', 'eme_ical_location_format', 'eme_ical_title_format', 'eme_ical_quote_tzid' ]; break; case 'rsvp': - $options = array( 'eme_default_contact_person', 'eme_rsvp_registered_users_only', 'eme_rsvp_reg_for_new_events', 'eme_rsvp_require_approval', 'eme_rsvp_require_user_confirmation', 'eme_rsvp_default_number_spaces', 'eme_rsvp_addbooking_min_spaces', 'eme_rsvp_addbooking_max_spaces', 'eme_rsvp_hide_full_events', 'eme_rsvp_hide_rsvp_ended_events', 'eme_rsvp_show_form_after_booking', 'eme_rsvp_addbooking_submit_string', 'eme_rsvp_delbooking_submit_string', 'eme_rsvp_not_yet_allowed_string', 'eme_rsvp_no_longer_allowed_string', 'eme_rsvp_full_string', 'eme_rsvp_on_waiting_list_string', 'eme_rsvp_cancel_no_longer_allowed_string', 'eme_attendees_list_format', 'eme_attendees_list_ignore_pending', 'eme_bookings_list_ignore_pending', 'eme_bookings_list_header_format', 'eme_bookings_list_format', 'eme_bookings_list_footer_format', 'eme_registration_recorded_ok_html', 'eme_registration_form_format', 'eme_cancel_form_format', 'eme_cancel_payment_form_format', 'eme_cancel_payment_line_format', 'eme_cancelled_payment_format', 'eme_rsvp_number_days', 'eme_rsvp_number_hours', 'eme_rsvp_end_target', 'eme_rsvp_check_required_fields', 'eme_cancel_rsvp_days', 'eme_cancel_rsvp_age', 'eme_rsvp_check_without_accents', 'eme_rsvp_admin_allow_overbooking', 'eme_rsvp_login_required_string', 'eme_rsvp_invitation_required_string', 'eme_rsvp_email_already_registered_string', 'eme_rsvp_person_already_registered_string', 'eme_check_free_waiting', 'eme_rsvp_pending_reminder_days', 'eme_rsvp_approved_reminder_days' ); + $options = [ 'eme_default_contact_person', 'eme_rsvp_registered_users_only', 'eme_rsvp_reg_for_new_events', 'eme_rsvp_require_approval', 'eme_rsvp_require_user_confirmation', 'eme_rsvp_default_number_spaces', 'eme_rsvp_addbooking_min_spaces', 'eme_rsvp_addbooking_max_spaces', 'eme_rsvp_hide_full_events', 'eme_rsvp_hide_rsvp_ended_events', 'eme_rsvp_show_form_after_booking', 'eme_rsvp_addbooking_submit_string', 'eme_rsvp_delbooking_submit_string', 'eme_rsvp_not_yet_allowed_string', 'eme_rsvp_no_longer_allowed_string', 'eme_rsvp_full_string', 'eme_rsvp_on_waiting_list_string', 'eme_rsvp_cancel_no_longer_allowed_string', 'eme_attendees_list_format', 'eme_attendees_list_ignore_pending', 'eme_bookings_list_ignore_pending', 'eme_bookings_list_header_format', 'eme_bookings_list_format', 'eme_bookings_list_footer_format', 'eme_registration_recorded_ok_html', 'eme_registration_form_format', 'eme_cancel_form_format', 'eme_cancel_payment_form_format', 'eme_cancel_payment_line_format', 'eme_cancelled_payment_format', 'eme_rsvp_number_days', 'eme_rsvp_number_hours', 'eme_rsvp_end_target', 'eme_rsvp_check_required_fields', 'eme_cancel_rsvp_days', 'eme_cancel_rsvp_age', 'eme_rsvp_check_without_accents', 'eme_rsvp_admin_allow_overbooking', 'eme_rsvp_login_required_string', 'eme_rsvp_invitation_required_string', 'eme_rsvp_email_already_registered_string', 'eme_rsvp_person_already_registered_string', 'eme_check_free_waiting', 'eme_rsvp_pending_reminder_days', 'eme_rsvp_approved_reminder_days' ]; break; case 'tasks': - $options = array( 'eme_task_registered_users_only', 'eme_task_allow_overlap', 'eme_task_form_taskentry_format', 'eme_task_form_format', 'eme_task_signup_format', 'eme_task_signup_recorded_ok_html', 'eme_task_signup_cancelled_ok_html', 'eme_task_reminder_days' ); + $options = [ 'eme_task_registered_users_only', 'eme_task_allow_overlap', 'eme_task_form_taskentry_format', 'eme_task_form_format', 'eme_task_signup_format', 'eme_task_signup_recorded_ok_html', 'eme_task_signup_cancelled_ok_html', 'eme_task_reminder_days' ]; break; case 'mail': - $options = array( 'eme_rsvp_mail_notify_is_active', 'eme_rsvp_mail_notify_pending', 'eme_rsvp_mail_notify_paid', 'eme_rsvp_mail_notify_approved', 'eme_mail_sender_name', 'eme_mail_sender_address', 'eme_mail_force_from', 'eme_rsvp_mail_send_method', 'eme_smtp_host', 'eme_smtp_port', 'eme_smtp_encryption', 'eme_rsvp_mail_SMTPAuth', 'eme_smtp_username', 'eme_smtp_password', 'eme_smtp_debug', 'eme_rsvp_send_html', 'eme_mail_bcc_address', 'eme_smtp_verify_cert', 'eme_queue_mails', 'eme_cron_send_queued', 'eme_cron_queue_count', 'eme_people_newsletter', 'eme_people_massmail', 'eme_massmail_popup_text', 'eme_massmail_popup', 'eme_mail_tracking', 'eme_mail_sleep', 'eme_mail_blacklist' ); + $options = [ 'eme_rsvp_mail_notify_is_active', 'eme_rsvp_mail_notify_pending', 'eme_rsvp_mail_notify_paid', 'eme_rsvp_mail_notify_approved', 'eme_mail_sender_name', 'eme_mail_sender_address', 'eme_mail_force_from', 'eme_rsvp_mail_send_method', 'eme_smtp_host', 'eme_smtp_port', 'eme_smtp_encryption', 'eme_rsvp_mail_SMTPAuth', 'eme_smtp_username', 'eme_smtp_password', 'eme_smtp_debug', 'eme_rsvp_send_html', 'eme_mail_bcc_address', 'eme_smtp_verify_cert', 'eme_queue_mails', 'eme_cron_send_queued', 'eme_cron_queue_count', 'eme_people_newsletter', 'eme_people_massmail', 'eme_massmail_popup_text', 'eme_massmail_popup', 'eme_mail_tracking', 'eme_mail_sleep', 'eme_mail_blacklist' ]; break; case 'mailtemplates': - $options = array( 'eme_contactperson_email_subject', 'eme_contactperson_cancelled_email_subject', 'eme_contactperson_pending_email_subject', 'eme_contactperson_email_body', 'eme_contactperson_cancelled_email_body', 'eme_contactperson_pending_email_body', 'eme_contactperson_ipn_email_subject', 'eme_contactperson_ipn_email_body', 'eme_contactperson_paid_email_subject', 'eme_contactperson_paid_email_body', 'eme_respondent_email_subject', 'eme_respondent_email_body', 'eme_registration_pending_email_subject', 'eme_registration_pending_email_body', 'eme_registration_userpending_email_subject', 'eme_registration_userpending_email_body', 'eme_registration_cancelled_email_subject', 'eme_registration_cancelled_email_body', 'eme_registration_trashed_email_subject', 'eme_registration_trashed_email_body', 'eme_registration_updated_email_subject', 'eme_registration_updated_email_body', 'eme_registration_paid_email_subject', 'eme_registration_paid_email_body', 'eme_registration_pending_reminder_email_subject', 'eme_registration_pending_reminder_email_body', 'eme_registration_reminder_email_subject', 'eme_registration_reminder_email_body', 'eme_sub_subject', 'eme_sub_body', 'eme_unsub_subject', 'eme_unsub_body', 'eme_booking_attach_ids', 'eme_pending_attach_ids', 'eme_paid_attach_ids', 'eme_subscribe_attach_ids', 'eme_full_name_format', 'eme_cp_task_signup_email_subject', 'eme_cp_task_signup_email_body', 'eme_cp_task_signup_cancelled_email_subject', 'eme_cp_task_signup_cancelled_email_body', 'eme_task_signup_email_subject', 'eme_task_signup_email_body', 'eme_task_signup_cancelled_email_subject', 'eme_task_signup_cancelled_email_body', 'eme_task_signup_trashed_email_subject', 'eme_task_signup_trashed_email_body', 'eme_task_signup_reminder_email_subject', 'eme_task_signup_reminder_email_body', 'eme_bd_email_subject', 'eme_bd_email_body' ); + $options = [ 'eme_contactperson_email_subject', 'eme_contactperson_cancelled_email_subject', 'eme_contactperson_pending_email_subject', 'eme_contactperson_email_body', 'eme_contactperson_cancelled_email_body', 'eme_contactperson_pending_email_body', 'eme_contactperson_ipn_email_subject', 'eme_contactperson_ipn_email_body', 'eme_contactperson_paid_email_subject', 'eme_contactperson_paid_email_body', 'eme_respondent_email_subject', 'eme_respondent_email_body', 'eme_registration_pending_email_subject', 'eme_registration_pending_email_body', 'eme_registration_userpending_email_subject', 'eme_registration_userpending_email_body', 'eme_registration_cancelled_email_subject', 'eme_registration_cancelled_email_body', 'eme_registration_trashed_email_subject', 'eme_registration_trashed_email_body', 'eme_registration_updated_email_subject', 'eme_registration_updated_email_body', 'eme_registration_paid_email_subject', 'eme_registration_paid_email_body', 'eme_registration_pending_reminder_email_subject', 'eme_registration_pending_reminder_email_body', 'eme_registration_reminder_email_subject', 'eme_registration_reminder_email_body', 'eme_sub_subject', 'eme_sub_body', 'eme_unsub_subject', 'eme_unsub_body', 'eme_booking_attach_ids', 'eme_pending_attach_ids', 'eme_paid_attach_ids', 'eme_subscribe_attach_ids', 'eme_full_name_format', 'eme_cp_task_signup_email_subject', 'eme_cp_task_signup_email_body', 'eme_cp_task_signup_cancelled_email_subject', 'eme_cp_task_signup_cancelled_email_body', 'eme_task_signup_email_subject', 'eme_task_signup_email_body', 'eme_task_signup_cancelled_email_subject', 'eme_task_signup_cancelled_email_body', 'eme_task_signup_trashed_email_subject', 'eme_task_signup_trashed_email_body', 'eme_task_signup_reminder_email_subject', 'eme_task_signup_reminder_email_body', 'eme_bd_email_subject', 'eme_bd_email_body' ]; break; case 'gdpr': - $options = array( 'eme_cpi_subject', 'eme_cpi_body', 'eme_cpi_form', 'eme_gdpr_subject', 'eme_gdpr_body', 'eme_gdpr_approve_subject', 'eme_gdpr_approve_body', 'eme_gdpr_page_title', 'eme_gdpr_page_header', 'eme_gdpr_page_footer', 'eme_gdpr_approve_page_title', 'eme_gdpr_approve_page_content', 'eme_gdpr_remove_expired_member_days', 'eme_gdpr_anonymize_old_bookings_days', 'eme_gdpr_remove_old_events_days', 'eme_gdpr_archive_old_mailings_days', 'eme_gdpr_remove_old_attendances_days', 'eme_gdpr_remove_old_signups_days' ); + $options = [ 'eme_cpi_subject', 'eme_cpi_body', 'eme_cpi_form', 'eme_gdpr_subject', 'eme_gdpr_body', 'eme_gdpr_approve_subject', 'eme_gdpr_approve_body', 'eme_gdpr_page_title', 'eme_gdpr_page_header', 'eme_gdpr_page_footer', 'eme_gdpr_approve_page_title', 'eme_gdpr_approve_page_content', 'eme_gdpr_remove_expired_member_days', 'eme_gdpr_anonymize_old_bookings_days', 'eme_gdpr_remove_old_events_days', 'eme_gdpr_archive_old_mailings_days', 'eme_gdpr_remove_old_attendances_days', 'eme_gdpr_remove_old_signups_days' ]; break; case 'payments': - $options = array( 'eme_default_vat', 'eme_payment_form_header_format', 'eme_payment_form_footer_format', 'eme_multipayment_form_header_format', 'eme_multipayment_form_footer_format', 'eme_payment_succes_format', 'eme_payment_fail_format', 'eme_payment_member_succes_format', 'eme_payment_member_fail_format', 'eme_payment_booking_already_paid_format', 'eme_payment_booking_on_waitinglist_format', 'eme_default_currency', 'eme_default_price', 'eme_payment_refund_ok', 'eme_pg_submit_immediately', 'eme_payment_redirect', 'eme_payment_redirect_wait', 'eme_payment_redirect_msg', 'eme_paypal_url', 'eme_paypal_clientid', 'eme_paypal_secret', 'eme_2co_demo', 'eme_2co_business', 'eme_2co_secret', 'eme_webmoney_purse', 'eme_webmoney_secret', 'eme_webmoney_demo', 'eme_fdgg_url', 'eme_fdgg_store_name', 'eme_fdgg_shared_secret', 'eme_2co_cost', 'eme_paypal_cost', 'eme_fdgg_cost', 'eme_webmoney_cost', 'eme_2co_cost2', 'eme_paypal_cost2', 'eme_fdgg_cost2', 'eme_webmoney_cost2', 'eme_mollie_api_key', 'eme_mollie_cost', 'eme_mollie_cost2', 'eme_paypal_button_label', 'eme_paypal_button_above', 'eme_paypal_button_below', 'eme_2co_button_label', 'eme_2co_button_above', 'eme_2co_button_below', 'eme_fdgg_button_label', 'eme_fdgg_button_above', 'eme_fdgg_button_below', 'eme_webmoney_button_label', 'eme_webmoney_button_above', 'eme_webmoney_button_below', 'eme_mollie_button_label', 'eme_mollie_button_above', 'eme_mollie_button_below', 'eme_paypal_button_img_url', 'eme_2co_button_img_url', 'eme_fdgg_button_img_url', 'eme_webmoney_button_img_url', 'eme_mollie_button_img_url', 'eme_worldpay_demo', 'eme_worldpay_instid', 'eme_worldpay_md5_secret', 'eme_worldpay_md5_parameters', 'eme_worldpay_test_pwd', 'eme_worldpay_live_pwd', 'eme_worldpay_cost', 'eme_worldpay_cost2', 'eme_worldpay_button_label', 'eme_worldpay_button_img_url', 'eme_worldpay_button_above', 'eme_worldpay_button_below', 'eme_braintree_private_key', 'eme_braintree_public_key', 'eme_braintree_merchant_id', 'eme_braintree_env', 'eme_braintree_cost', 'eme_braintree_cost2', 'eme_braintree_button_label', 'eme_braintree_button_img_url', 'eme_braintree_button_above', 'eme_braintree_button_below', 'eme_stripe_private_key', 'eme_stripe_public_key', 'eme_stripe_cost', 'eme_stripe_cost2', 'eme_stripe_button_label', 'eme_stripe_button_img_url', 'eme_stripe_button_above', 'eme_stripe_button_below', 'eme_stripe_payment_methods', 'eme_offline_payment', 'eme_legacypaypal_url', 'eme_legacypaypal_business', 'eme_legacypaypal_no_tax', 'eme_legacypaypal_cost', 'eme_legacypaypal_cost2', 'eme_legacypaypal_button_label', 'eme_legacypaypal_button_img_url', 'eme_legacypaypal_button_above', 'eme_legacypaypal_button_below', 'eme_instamojo_env', 'eme_instamojo_key', 'eme_instamojo_auth_token', 'eme_instamojo_salt', 'eme_instamojo_cost', 'eme_instamojo_cost2', 'eme_instamojo_button_label', 'eme_instamojo_button_img_url', 'eme_instamojo_button_above', 'eme_instamojo_button_below', 'eme_mercadopago_demo', 'eme_mercadopago_sandbox_token', 'eme_mercadopago_live_token', 'eme_mercadopago_cost', 'eme_mercadopago_cost2', 'eme_mercadopago_button_label', 'eme_mercadopago_button_img_url', 'eme_mercadopago_button_above', 'eme_mercadopago_button_below', 'eme_fondy_merchant_id', 'eme_fondy_secret_key', 'eme_fondy_cost', 'eme_fondy_cost2', 'eme_fondy_button_label', 'eme_fondy_button_img_url', 'eme_fondy_button_above', 'eme_fondy_button_below', 'eme_payconiq_api_key', 'eme_payconiq_env', 'eme_payconiq_merchant_id', 'eme_payconiq_cost', 'eme_payconiq_cost2', 'eme_payconiq_button_label', 'eme_payconiq_button_img_url', 'eme_payconiq_button_above', 'eme_payconiq_button_below', 'eme_sumup_merchant_code', 'eme_sumup_app_id', 'eme_sumup_app_secret', 'eme_sumup_cost', 'eme_sumup_cost2', 'eme_sumup_button_label', 'eme_sumup_button_img_url', 'eme_sumup_button_above', 'eme_sumup_button_below', 'eme_opayo_demo', 'eme_opayo_vendor_name', 'eme_opayo_test_pwd', 'eme_opayo_live_pwd', 'eme_opayo_cost', 'eme_opayo_cost2', 'eme_opayo_button_label', 'eme_opayo_button_img_url', 'eme_opayo_button_above', 'eme_opayo_button_below' ); + $options = [ 'eme_default_vat', 'eme_payment_form_header_format', 'eme_payment_form_footer_format', 'eme_multipayment_form_header_format', 'eme_multipayment_form_footer_format', 'eme_payment_succes_format', 'eme_payment_fail_format', 'eme_payment_member_succes_format', 'eme_payment_member_fail_format', 'eme_payment_booking_already_paid_format', 'eme_payment_booking_on_waitinglist_format', 'eme_default_currency', 'eme_default_price', 'eme_payment_refund_ok', 'eme_pg_submit_immediately', 'eme_payment_redirect', 'eme_payment_redirect_wait', 'eme_payment_redirect_msg', 'eme_paypal_url', 'eme_paypal_clientid', 'eme_paypal_secret', 'eme_2co_demo', 'eme_2co_business', 'eme_2co_secret', 'eme_webmoney_purse', 'eme_webmoney_secret', 'eme_webmoney_demo', 'eme_fdgg_url', 'eme_fdgg_store_name', 'eme_fdgg_shared_secret', 'eme_2co_cost', 'eme_paypal_cost', 'eme_fdgg_cost', 'eme_webmoney_cost', 'eme_2co_cost2', 'eme_paypal_cost2', 'eme_fdgg_cost2', 'eme_webmoney_cost2', 'eme_mollie_api_key', 'eme_mollie_cost', 'eme_mollie_cost2', 'eme_paypal_button_label', 'eme_paypal_button_above', 'eme_paypal_button_below', 'eme_2co_button_label', 'eme_2co_button_above', 'eme_2co_button_below', 'eme_fdgg_button_label', 'eme_fdgg_button_above', 'eme_fdgg_button_below', 'eme_webmoney_button_label', 'eme_webmoney_button_above', 'eme_webmoney_button_below', 'eme_mollie_button_label', 'eme_mollie_button_above', 'eme_mollie_button_below', 'eme_paypal_button_img_url', 'eme_2co_button_img_url', 'eme_fdgg_button_img_url', 'eme_webmoney_button_img_url', 'eme_mollie_button_img_url', 'eme_worldpay_demo', 'eme_worldpay_instid', 'eme_worldpay_md5_secret', 'eme_worldpay_md5_parameters', 'eme_worldpay_test_pwd', 'eme_worldpay_live_pwd', 'eme_worldpay_cost', 'eme_worldpay_cost2', 'eme_worldpay_button_label', 'eme_worldpay_button_img_url', 'eme_worldpay_button_above', 'eme_worldpay_button_below', 'eme_braintree_private_key', 'eme_braintree_public_key', 'eme_braintree_merchant_id', 'eme_braintree_env', 'eme_braintree_cost', 'eme_braintree_cost2', 'eme_braintree_button_label', 'eme_braintree_button_img_url', 'eme_braintree_button_above', 'eme_braintree_button_below', 'eme_stripe_private_key', 'eme_stripe_public_key', 'eme_stripe_cost', 'eme_stripe_cost2', 'eme_stripe_button_label', 'eme_stripe_button_img_url', 'eme_stripe_button_above', 'eme_stripe_button_below', 'eme_stripe_payment_methods', 'eme_offline_payment', 'eme_legacypaypal_url', 'eme_legacypaypal_business', 'eme_legacypaypal_no_tax', 'eme_legacypaypal_cost', 'eme_legacypaypal_cost2', 'eme_legacypaypal_button_label', 'eme_legacypaypal_button_img_url', 'eme_legacypaypal_button_above', 'eme_legacypaypal_button_below', 'eme_instamojo_env', 'eme_instamojo_key', 'eme_instamojo_auth_token', 'eme_instamojo_salt', 'eme_instamojo_cost', 'eme_instamojo_cost2', 'eme_instamojo_button_label', 'eme_instamojo_button_img_url', 'eme_instamojo_button_above', 'eme_instamojo_button_below', 'eme_mercadopago_demo', 'eme_mercadopago_sandbox_token', 'eme_mercadopago_live_token', 'eme_mercadopago_cost', 'eme_mercadopago_cost2', 'eme_mercadopago_button_label', 'eme_mercadopago_button_img_url', 'eme_mercadopago_button_above', 'eme_mercadopago_button_below', 'eme_fondy_merchant_id', 'eme_fondy_secret_key', 'eme_fondy_cost', 'eme_fondy_cost2', 'eme_fondy_button_label', 'eme_fondy_button_img_url', 'eme_fondy_button_above', 'eme_fondy_button_below', 'eme_payconiq_api_key', 'eme_payconiq_env', 'eme_payconiq_merchant_id', 'eme_payconiq_cost', 'eme_payconiq_cost2', 'eme_payconiq_button_label', 'eme_payconiq_button_img_url', 'eme_payconiq_button_above', 'eme_payconiq_button_below', 'eme_sumup_merchant_code', 'eme_sumup_app_id', 'eme_sumup_app_secret', 'eme_sumup_cost', 'eme_sumup_cost2', 'eme_sumup_button_label', 'eme_sumup_button_img_url', 'eme_sumup_button_above', 'eme_sumup_button_below', 'eme_opayo_demo', 'eme_opayo_vendor_name', 'eme_opayo_test_pwd', 'eme_opayo_live_pwd', 'eme_opayo_cost', 'eme_opayo_cost2', 'eme_opayo_button_label', 'eme_opayo_button_img_url', 'eme_opayo_button_above', 'eme_opayo_button_below' ]; break; case 'maps': - $options = array( 'eme_indiv_zoom_factor', 'eme_map_zooming', 'eme_location_baloon_format', 'eme_location_map_icon', 'eme_map_gesture_handling' ); + $options = [ 'eme_indiv_zoom_factor', 'eme_map_zooming', 'eme_location_baloon_format', 'eme_location_map_icon', 'eme_map_gesture_handling' ]; break; case 'other': - $options = array( 'eme_thumbnail_size', 'eme_image_max_width', 'eme_image_max_height', 'eme_image_max_size', 'eme_html_header', 'eme_html_footer', 'eme_event_html_headers_format', 'eme_location_html_headers_format', 'eme_csv_separator', 'eme_use_external_url', 'eme_bd_email', 'eme_bd_email_members_only', 'eme_time_remove_leading_zeros', 'eme_stay_on_edit_page', 'eme_localize_price', 'eme_decimals', 'eme_timepicker_minutesstep', 'eme_form_required_field_string', 'eme_allowed_html', 'eme_allowed_style_attr', 'eme_version', 'eme_pdf_font', 'eme_backend_dateformat', 'eme_backend_timeformat', 'eme_unique_email_per_person', 'eme_address1_string', 'eme_address2_string', 'eme_multisite_active' ); + $options = [ 'eme_thumbnail_size', 'eme_image_max_width', 'eme_image_max_height', 'eme_image_max_size', 'eme_html_header', 'eme_html_footer', 'eme_event_html_headers_format', 'eme_location_html_headers_format', 'eme_csv_separator', 'eme_use_external_url', 'eme_bd_email', 'eme_bd_email_members_only', 'eme_time_remove_leading_zeros', 'eme_stay_on_edit_page', 'eme_localize_price', 'eme_decimals', 'eme_timepicker_minutesstep', 'eme_form_required_field_string', 'eme_allowed_html', 'eme_allowed_style_attr', 'eme_version', 'eme_pdf_font', 'eme_backend_dateformat', 'eme_backend_timeformat', 'eme_unique_email_per_person', 'eme_address1_string', 'eme_address2_string', 'eme_multisite_active' ]; break; } @@ -1054,7 +1054,7 @@ function eme_sanitize_options( $input ) { // allow js only in very specific header settings //$allow_js_arr=array('eme_html_header','eme_html_footer','eme_event_html_headers_format','eme_location_html_headers_format','eme_payment_form_header_format','eme_payment_form_footer_format','eme_multipayment_form_header_format','eme_multipayment_form_footer_format','eme_payment_succes_format','eme_payment_fail_format','eme_payment_member_succes_format','eme_payment_member_fail_format','eme_registration_recorded_ok_html'); if ( is_array( $input ) ) { - $output = array(); + $output = []; foreach ($input as $key=>$value) { //if (in_array($key,$allow_js_arr)) // $output[$key]=$value; @@ -1068,7 +1068,7 @@ function eme_sanitize_options( $input ) { } function eme_admin_tabs( $current = 'homepage' ) { - $tabs = array( + $tabs = [ 'general' => __( 'General', 'events-made-easy' ), 'access' => __( 'Access', 'events-made-easy' ), 'seo' => __( 'SEO', 'events-made-easy' ), @@ -1085,7 +1085,7 @@ function eme_admin_tabs( $current = 'homepage' ) { 'payments' => __( 'Payments', 'events-made-easy' ), 'maps' => __( 'Maps', 'events-made-easy' ), 'other' => __( 'Other', 'events-made-easy' ), - ); + ]; if ( ! get_option( 'eme_rsvp_enabled' ) ) { unset( $tabs['rsvp'] ); } @@ -1245,18 +1245,18 @@ function eme_options_page() { eme_options_input_text( __( 'hCaptcha site key', 'events-made-easy' ), 'eme_hcaptcha_site_key', __( 'This field is required', 'events-made-easy' ) ); eme_options_input_text( __( 'hCaptcha secret key', 'events-made-easy' ), 'eme_hcaptcha_secret_key', __( 'This field is required', 'events-made-easy' ) ); eme_options_select( - __( 'Autocomplete sources', 'events-made-easy' ), - 'eme_autocomplete_sources', - array( + __( 'Autocomplete sources', 'events-made-easy' ), + 'eme_autocomplete_sources', + [ 'none' => __( 'None', 'events-made-easy' ), 'people' => __( 'EME people', 'events-made-easy' ), 'wp_users' => __( 'Wordpress users', 'events-made-easy' ), 'both' => __( - 'Both EME people and WP users', - 'events-made-easy' + 'Both EME people and WP users', + 'events-made-easy' ), - ), - __( 'Decide if autocompletion is used in RSVP or membership forms and select if you want to search EME people, WP users or both. The autocompletion only works on the lastname field and only if you have sufficient rights (event creator or event author).', 'events-made-easy' ) + ], + __( 'Decide if autocompletion is used in RSVP or membership forms and select if you want to search EME people, WP users or both. The autocompletion only works on the lastname field and only if you have sufficient rights (event creator or event author).', 'events-made-easy' ) ); eme_options_radio_binary( __( 'Delete all stored EME data when upgrading or deactivating?', 'events-made-easy' ), 'eme_uninstall_drop_data', __( 'Check this option if you want to delete all EME data concerning events, bookings, ... when upgrading or deactivating the plugin.', 'events-made-easy' ) ); eme_options_radio_binary( __( 'Delete all EME settings when upgrading or deactivating?', 'events-made-easy' ), 'eme_uninstall_drop_settings', __( 'Check this option if you want to delete all EME settings when upgrading or deactivating the plugin.', 'events-made-easy' ) ); @@ -1579,10 +1579,10 @@ function eme_options_page() { __( 'starts', 'events-made-easy' ), 'end' => __( 'ends', 'events-made-easy' ), - ); + ]; esc_html_e( 'before the event ', 'events-made-easy' ); echo eme_ui_select( $eme_rsvp_end_target, 'eme_rsvp_end_target', $eme_rsvp_end_target_list ); ?> @@ -1712,31 +1712,31 @@ function eme_options_page() { eme_options_radio_binary( __( 'Force sender address everywhere', 'events-made-easy' ), 'eme_mail_force_from', __( 'Force the configured sender address to be used for all outgoing emails. If not activated, the name and email address of the default contact person for RSVP mails will be used for generic mails, while for event or membership related mails the configured contact person will be used (or the blog admin if empty).', 'events-made-easy' ) ); eme_options_input_text( __( 'Default email BCC', 'events-made-easy' ), 'eme_mail_bcc_address', __( 'Insert an email address that will be added in Bcc to all outgoing mails (multiple addresses are to be separated by comma or semicolon). Can be left empty.', 'events-made-easy' ) ); eme_options_select( - __( 'Email sending method', 'events-made-easy' ), - 'eme_rsvp_mail_send_method', - array( + __( 'Email sending method', 'events-made-easy' ), + 'eme_rsvp_mail_send_method', + [ 'smtp' => 'SMTP', 'mail' => __( 'PHP email function', 'events-made-easy' ), 'sendmail' => 'Sendmail', 'qmail' => 'Qmail', 'wp_mail' => 'Wordpress Email (default)', - ), - __( 'Select how you want to send out emails.', 'events-made-easy' ) + ], + __( 'Select how you want to send out emails.', 'events-made-easy' ) ); eme_options_input_text( __( 'SMTP host', 'events-made-easy' ), 'eme_smtp_host', __( "The SMTP host. Usually it corresponds to 'localhost'.", 'events-made-easy' ) ); eme_options_input_text( __( 'SMTP port', 'events-made-easy' ), 'eme_smtp_port', __( "The port through which you email notifications will be sent. Make sure the firewall doesn't block this port", 'events-made-easy' ) ); eme_options_select( - __( 'SMTP encryption method', 'events-made-easy' ), - 'eme_smtp_encryption', - array( + __( 'SMTP encryption method', 'events-made-easy' ), + 'eme_smtp_encryption', + [ 'none' => __( 'None', 'events-made-easy' ), 'tls' => __( 'TLS', 'events-made-easy' ), 'ssl' => __( - 'SSL', - 'events-made-easy' + 'SSL', + 'events-made-easy' ), - ), - __( 'Select the SMTP encryption method.', 'events-made-easy' ) + ], + __( 'Select the SMTP encryption method.', 'events-made-easy' ) ); eme_options_radio_binary( __( 'Use SMTP authentication?', 'events-made-easy' ), 'eme_rsvp_mail_SMTPAuth', __( 'SMTP authentication is often needed. If you use Gmail, make sure to set this parameter to Yes', 'events-made-easy' ) ); eme_options_input_text( __( 'SMTP username', 'events-made-easy' ), 'eme_smtp_username', __( 'Insert the username to be used to access your SMTP server.', 'events-made-easy' ) ); @@ -2168,16 +2168,16 @@ function eme_options_page() { " . __( 'Remark: due to the incomplete PHP implementation by Paypal, it is not recommended to use this method. It works fine, but has some shortcomings: no webhook functionality (meaning: if someone closes the browser immediately after payment, the payment will not get marked as paid in EME) and refunding is not possible.', 'events-made-easy' ) . ''; eme_options_select( - __( 'PayPal live or test', 'events-made-easy' ), - 'eme_paypal_url', - array( + __( 'PayPal live or test', 'events-made-easy' ), + 'eme_paypal_url', + [ 'sandbox' => __( 'Paypal Sandbox (for testing)', 'events-made-easy' ), 'live' => __( - 'Paypal Live', - 'events-made-easy' + 'Paypal Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test paypal in a paypal sandbox or go live and really use paypal.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test paypal in a paypal sandbox or go live and really use paypal.', 'events-made-easy' ) ); eme_options_input_text( __( 'PayPal client ID', 'events-made-easy' ), 'eme_paypal_clientid', __( 'Paypal client ID.', 'events-made-easy' ) . '
    ' . sprintf( __( 'For more info on Paypal apps and credentials, see this page', 'events-made-easy' ), 'https://developer.paypal.com/docs/integration/admin/manage-apps/#create-an-app-for-testing' ) ); eme_options_input_text( __( 'PayPal secret', 'events-made-easy' ), 'eme_paypal_secret', __( 'Paypal secret.', 'events-made-easy' ) . '
    ' . sprintf( __( 'For more info on Paypal apps and credentials, see this page', 'events-made-easy' ), 'https://developer.paypal.com/docs/integration/admin/manage-apps/#create-an-app-for-testing' ) ); @@ -2197,18 +2197,18 @@ function eme_options_page() {
    'legacypaypal_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'legacypaypal_notification' ], $events_page_link ); eme_options_select( - __( 'PayPal live or test', 'events-made-easy' ), - 'eme_legacypaypal_url', - array( + __( 'PayPal live or test', 'events-made-easy' ), + 'eme_legacypaypal_url', + [ 'sandbox' => __( 'Paypal Sandbox (for testing)', 'events-made-easy' ), 'live' => __( - 'Paypal Live', - 'events-made-easy' + 'Paypal Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test paypal in a paypal sandbox or go live and really use paypal.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test paypal in a paypal sandbox or go live and really use paypal.', 'events-made-easy' ) ); eme_options_input_text( __( 'PayPal business info', 'events-made-easy' ), 'eme_legacypaypal_business', __( 'Paypal business ID or email.', 'events-made-easy' ) ); eme_options_radio_binary( __( 'Ignore Paypal tax setting?', 'events-made-easy' ), 'eme_legacypaypal_no_tax', __( 'Select yes to ignore the tax setting in your Paypal profile.', 'events-made-easy' ) ); @@ -2230,20 +2230,20 @@ function eme_options_page() {
    '2co_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => '2co_notification' ], $events_page_link ); eme_options_select( - __( '2Checkout live or test', 'events-made-easy' ), - 'eme_2co_demo', - array( + __( '2Checkout live or test', 'events-made-easy' ), + 'eme_2co_demo', + [ 2 => __( '2Checkout Sandbox (for testing)', 'events-made-easy' ), 1 => __( '2Checkout Test (the "demo" mode)', 'events-made-easy' ), 0 => __( - '2Checkout Live', - 'events-made-easy' + '2Checkout Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test 2Checkout in a sandbox or go live and really use 2Checkout.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test 2Checkout in a sandbox or go live and really use 2Checkout.', 'events-made-easy' ) ); eme_options_input_text( __( '2Checkout Account number', 'events-made-easy' ), 'eme_2co_business', __( '2Checkout Account number.', 'events-made-easy' ) ); eme_options_input_password( __( '2Checkout Secret', 'events-made-easy' ), 'eme_2co_secret', __( '2Checkout secret.', 'events-made-easy' ) ); @@ -2264,19 +2264,19 @@ function eme_options_page() {
    'webmoney_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'webmoney_notification' ], $events_page_link ); eme_options_select( - __( 'Webmoney live or test', 'events-made-easy' ), - 'eme_webmoney_demo', - array( + __( 'Webmoney live or test', 'events-made-easy' ), + 'eme_webmoney_demo', + [ 1 => __( 'Webmoney Sandbox (for testing)', 'events-made-easy' ), 0 => __( - 'Webmoney Live', - 'events-made-easy' + 'Webmoney Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test Webmoney in a sandbox or go live and really use Webmoney.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test Webmoney in a sandbox or go live and really use Webmoney.', 'events-made-easy' ) ); eme_options_input_text( __( 'Webmoney Purse', 'events-made-easy' ), 'eme_webmoney_purse', __( 'Webmoney Purse.', 'events-made-easy' ) ); eme_options_input_password( __( 'Webmoney Secret', 'events-made-easy' ), 'eme_webmoney_secret', __( 'Webmoney secret.', 'events-made-easy' ) ); @@ -2297,19 +2297,19 @@ function eme_options_page() {
    'fdgg_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'fdgg_notification' ], $events_page_link ); eme_options_select( - __( 'First Data live or test', 'events-made-easy' ), - 'eme_fdgg_url', - array( + __( 'First Data live or test', 'events-made-easy' ), + 'eme_fdgg_url', + [ 'sandbox' => __( 'First Data Sandbox (for testing)', 'events-made-easy' ), 'live' => __( - 'First Data Live', - 'events-made-easy' + 'First Data Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test First Data in a sandbox or go live and really use First Data.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test First Data in a sandbox or go live and really use First Data.', 'events-made-easy' ) ); eme_options_input_text( __( 'First Data Store Name', 'events-made-easy' ), 'eme_fdgg_store_name', __( 'First Data Store Name.', 'events-made-easy' ) ); eme_options_input_password( __( 'First Data Shared Secret', 'events-made-easy' ), 'eme_fdgg_shared_secret', __( 'First Data Shared Secret.', 'events-made-easy' ) ); @@ -2330,7 +2330,7 @@ function eme_options_page() {
    'mollie_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'mollie_notification' ], $events_page_link ); eme_options_input_text( __( 'Mollie API key', 'events-made-easy' ), 'eme_mollie_api_key', __( 'Mollie API key', 'events-made-easy' ) ); $gateway = 'mollie'; @@ -2350,18 +2350,18 @@ function eme_options_page() {
    'payconiq_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'payconiq_notification' ], $events_page_link ); eme_options_select( - __( 'Payconiq live or test', 'events-made-easy' ), - 'eme_payconiq_env', - array( + __( 'Payconiq live or test', 'events-made-easy' ), + 'eme_payconiq_env', + [ 'sandbox' => __( 'Payconiq Sandbox (for testing)', 'events-made-easy' ), 'production' => __( - 'Payconiq Live', - 'events-made-easy' + 'Payconiq Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test Payconiq in a sandbox or go live and really use Payconiq.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test Payconiq in a sandbox or go live and really use Payconiq.', 'events-made-easy' ) ); eme_options_input_text( __( 'Payconiq API key', 'events-made-easy' ), 'eme_payconiq_api_key', __( 'Payconiq API key', 'events-made-easy' ) ); eme_options_input_text( __( 'Payconiq Merchant ID', 'events-made-easy' ), 'eme_payconiq_merchant_id', __( 'Payconiq Merchant ID', 'events-made-easy' ) ); @@ -2382,18 +2382,18 @@ function eme_options_page() {
    'worldpay_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'worldpay_notification' ], $events_page_link ); eme_options_select( - __( 'Worldpay live or test', 'events-made-easy' ), - 'eme_worldpay_demo', - array( + __( 'Worldpay live or test', 'events-made-easy' ), + 'eme_worldpay_demo', + [ 1 => __( 'Worldpay Sandbox (for testing)', 'events-made-easy' ), 0 => __( - 'Worldpay Live', - 'events-made-easy' + 'Worldpay Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test Worldpay in a sandbox or go live and really use Worldpay.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test Worldpay in a sandbox or go live and really use Worldpay.', 'events-made-easy' ) ); eme_options_input_text( __( 'Worldpay installation ID', 'events-made-easy' ), 'eme_worldpay_instid', __( 'Worldpay installation ID', 'events-made-easy' ) ); eme_options_input_text( __( 'Worldpay MD5 secret', 'events-made-easy' ), 'eme_worldpay_md5_secret', __( 'Worldpay MD5 secret used when submitting payments', 'events-made-easy' ) ); @@ -2418,16 +2418,16 @@ function eme_options_page() {
    __( 'Opayo Sandbox (for testing)', 'events-made-easy' ), 0 => __( - 'Opayo Live', - 'events-made-easy' + 'Opayo Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test Opayo in a sandbox or go live and really use Opayo.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test Opayo in a sandbox or go live and really use Opayo.', 'events-made-easy' ) ); eme_options_input_text( __( 'Opayo Vendor Name', 'events-made-easy' ), 'eme_opayo_vendor_name', __( 'Opayo Vendor Name', 'events-made-easy' ) ); eme_options_input_password( __( 'Opayo Test Password', 'events-made-easy' ), 'eme_opayo_test_pwd', __( 'Opayo password for testing purposes', 'events-made-easy' ) ); @@ -2449,7 +2449,7 @@ function eme_options_page() {
    'sumup_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'sumup_notification' ], $events_page_link ); eme_options_input_text( __( 'SumUp Merchant Code', 'events-made-easy' ), 'eme_sumup_merchant_code', __( 'SumUp Merchant Code', 'events-made-easy' ) ); eme_options_input_text( __( 'SumUp App ID', 'events-made-easy' ), 'eme_sumup_app_id', __( 'SumUp App ID', 'events-made-easy' ) ); eme_options_input_text( __( 'SumUp App Secret', 'events-made-easy' ), 'eme_sumup_app_secret', __( 'SumUp App Secret', 'events-made-easy' ) ); @@ -2470,7 +2470,7 @@ function eme_options_page() {
    'stripe_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'stripe_notification' ], $events_page_link ); eme_options_input_text( __( 'Stripe Secret Key', 'events-made-easy' ), 'eme_stripe_private_key', __( 'Stripe Secret Key', 'events-made-easy' ) ); eme_options_input_text( __( 'Stripe Public Key', 'events-made-easy' ), 'eme_stripe_public_key', __( 'Stripe Public Key', 'events-made-easy' ) ); $gateway = 'stripe'; @@ -2480,7 +2480,7 @@ function eme_options_page() { eme_options_input_text( __( 'Payment button image', 'events-made-easy' ), 'eme_' . $gateway . '_button_img_url', __( 'The url to an image for the payment button that replaces the standard submit button with the label mentioned above.', 'events-made-easy' ) ); eme_options_input_text( __( 'Text above payment button', 'events-made-easy' ), 'eme_' . $gateway . '_button_above', __( 'The text shown just above the payment button', 'events-made-easy' ) . '
    ' . __( 'For all possible placeholders, see ', 'events-made-easy' ) . "" . __( 'the documentation', 'events-made-easy' ) . '' ); eme_options_input_text( __( 'Text below payment button', 'events-made-easy' ), 'eme_' . $gateway . '_button_below', __( 'The text shown just below the payment button', 'events-made-easy' ) . '
    ' . __( 'For all possible placeholders, see ', 'events-made-easy' ) . "" . __( 'the documentation', 'events-made-easy' ) . '' ); - $stripe_pms = array( + $stripe_pms = [ 'alipay' => 'alipay', 'card' => 'card', 'ideal' => 'ideal', @@ -2498,7 +2498,7 @@ function eme_options_page() { 'wechat_pay' => 'wechat_pay', 'boleto' => 'boleto', 'oxxo' => 'oxxo', - ); + ]; eme_options_multiselect( __( 'Stripe payment methods', 'events-made-easy' ), 'eme_stripe_payment_methods', $stripe_pms, __( "The different Stripe payment methods you want to handle/provide. Defaults to 'card'. See the Stripe doc for more info.", 'events-made-easy' ), false, 'eme_select2_width50_class' ); echo "'; @@ -2526,16 +2526,16 @@ function eme_options_page() {
    " . esc_html__( 'Info: the url for payment notifications is: ', 'events-made-easy' ) . $notification_link . '
    __( 'Braintree Sandbox (for testing)', 'events-made-easy' ), 'production' => __( - 'Braintree Live', - 'events-made-easy' + 'Braintree Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test Braintree in a sandbox or go live and really use Braintree.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test Braintree in a sandbox or go live and really use Braintree.', 'events-made-easy' ) ); eme_options_input_text( __( 'Braintree Merchant ID', 'events-made-easy' ), 'eme_braintree_merchant_id', __( 'Braintree Merchant ID', 'events-made-easy' ) ); eme_options_input_text( __( 'Braintree Public Key', 'events-made-easy' ), 'eme_braintree_public_key', __( 'Braintree Public Key', 'events-made-easy' ) ); @@ -2557,16 +2557,16 @@ function eme_options_page() {
    __( 'Instamojo Sandbox (for testing)', 'events-made-easy' ), 'production' => __( - 'Instamojo Live', - 'events-made-easy' + 'Instamojo Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test Instamojo in a sandbox or go live and really use Instamojo.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test Instamojo in a sandbox or go live and really use Instamojo.', 'events-made-easy' ) ); eme_options_input_text( __( 'Instamojo Private Key', 'events-made-easy' ), 'eme_instamojo_key', __( 'Instamojo Private Key', 'events-made-easy' ) ); eme_options_input_text( __( 'Instamojo Private Auth Token', 'events-made-easy' ), 'eme_instamojo_auth_token', __( 'Instamojo Private Auth Token', 'events-made-easy' ) ); @@ -2588,16 +2588,16 @@ function eme_options_page() {
    __( 'Mercado Pago Sandbox (for testing)', 'events-made-easy' ), 0 => __( - 'Mercado Pago Live', - 'events-made-easy' + 'Mercado Pago Live', + 'events-made-easy' ), - ), - __( 'Choose wether you want to test Mercado Pago in a sandbox or go live and really use Mercado Pago.', 'events-made-easy' ) + ], + __( 'Choose wether you want to test Mercado Pago in a sandbox or go live and really use Mercado Pago.', 'events-made-easy' ) ); eme_options_input_text( __( 'Mercado Pago Sandbox Access Token', 'events-made-easy' ), 'eme_mercadopago_sandbox_token', __( 'Mercado Pago Sandbox Access Token', 'events-made-easy' ) ); eme_options_input_text( __( 'Mercado Pago Live Access Token', 'events-made-easy' ), 'eme_mercadopago_live_token', __( 'Mercado Pago Live Access Token', 'events-made-easy' ) ); @@ -2677,7 +2677,7 @@ function eme_options_page() { require_once 'dompdf/2.0.1/vendor/autoload.php'; $dompdf = new Dompdf\Dompdf(); $dompdf_fontfamilies = array_keys( $dompdf->getFontMetrics()->getFontFamilies() ); - $pdf_font_families_arr = array(); + $pdf_font_families_arr = []; foreach ( $dompdf_fontfamilies as $font ) { $pdf_font_families_arr[ $font ] = ucwords( $font ); } diff --git a/eme-payments.php b/eme-payments.php index 2a7cce21..02c22dec 100644 --- a/eme-payments.php +++ b/eme-payments.php @@ -5,7 +5,7 @@ } function eme_payment_gateways() { - $pgs = array( + $pgs = [ 'paypal' => __( 'Paypal', 'events-made-easy' ), 'legacypaypal' => __( 'Legacy Paypal', 'events-made-easy' ), '2co' => __( '2Checkout', 'events-made-easy' ), @@ -22,7 +22,7 @@ function eme_payment_gateways() { 'mercadopago' => __( 'Mercado Pago', 'events-made-easy' ), 'fondy' => __( 'Fondy', 'events-made-easy' ), 'offline' => __( 'Offline', 'events-made-easy' ), - ); + ]; // allow people to change the sequence or (in the future) even add their own payment gateway if ( has_filter( 'eme_payment_gateways' ) ) { @@ -32,9 +32,9 @@ function eme_payment_gateways() { } function eme_is_offline_pg( $pg ) { - $pgs = array( + $pgs = [ 'offline', - ); + ]; if ( has_filter( 'eme_offline_payment_gateways' ) ) { $pgs = apply_filters( 'eme_offline_payment_gateways', $pgs ); } @@ -88,7 +88,7 @@ function eme_payment_form( $payment_id, $resultcode = 0, $standalone = 0 ) { // if the booking was userpending, confirm it and set a message if ( $booking['status'] == EME_RSVP_STATUS_USERPENDING ) { // we arrive here, so: mark all the bookings as confirmed by the user and continue - $booking_ids = array(); + $booking_ids = []; foreach ( $bookings as $booking ) { $booking_ids[] = $booking['booking_id']; } @@ -444,7 +444,7 @@ function eme_webmoney_form( $item_name, $payment, $baseprice, $cur, $multi_booki $payment_id = $payment['id']; $success_link = eme_payment_return_url( $payment, 0 ); $fail_link = eme_payment_return_url( $payment, 1 ); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'webmoney_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'webmoney_notification' ], $events_page_link ); if ( $payment['target'] == 'member' ) { $description = sprintf( __( "Member signup for '%s'", 'events-made-easy' ), $item_name ); @@ -578,7 +578,7 @@ function eme_worldpay_form( $item_name, $payment, $baseprice, $cur, $multi_booki $payment_id = $payment['id']; // $success_link = eme_payment_return_url($payment,0); // $fail_link = eme_payment_return_url($payment,1); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'worldpay_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'worldpay_notification' ], $events_page_link ); if ( $payment['target'] == 'member' ) { $description = sprintf( __( "Member signup for '%s'", 'events-made-easy' ), $item_name ); $filtername = 'eme_member_paymentform_description_filter'; @@ -656,8 +656,8 @@ function eme_opayo_form( $item_name, $payment, $baseprice, $cur, $multi_booking $fail_link = eme_payment_return_url( $payment, 1 ); // opayo doesn't use a notification url, but sends the status along as part of the return url // so we add the notification info to it too, so we can process paid info as usual - $success_link = add_query_arg( array( 'eme_eventAction' => 'opayo_notification' ), $success_link ); - $fail_link = add_query_arg( array( 'eme_eventAction' => 'opayo_notification' ), $fail_link ); + $success_link = add_query_arg( [ 'eme_eventAction' => 'opayo_notification' ], $success_link ); + $fail_link = add_query_arg( [ 'eme_eventAction' => 'opayo_notification' ], $fail_link ); if ( $payment['target'] == 'member' ) { $description = sprintf( __( "Member signup for '%s'", 'events-made-easy' ), $item_name ); @@ -692,7 +692,7 @@ function eme_opayo_form( $item_name, $payment, $baseprice, $cur, $multi_booking $button_below = get_option( 'eme_' . $gateway . '_button_below' ); $button_img_url = get_option( 'eme_' . $gateway . '_button_img_url' ); - $person = array(); + $person = []; if ( $payment['target'] == 'member' ) { $member = eme_get_member_by_paymentid( $payment_id ); if ( $member ) { @@ -709,7 +709,7 @@ function eme_opayo_form( $item_name, $payment, $baseprice, $cur, $multi_booking $person = eme_new_person(); } - $query = array( + $query = [ 'VendorTxCode' => $payment_id, 'Amount' => number_format( $price, 2, '.', '' ), 'Currency' => $cur, @@ -730,7 +730,7 @@ function eme_opayo_form( $item_name, $payment, $baseprice, $cur, $multi_booking 'DeliveryPostCode' => $person['zip'], 'DeliveryState' => $person['state_code'], 'DeliveryCountry' => $person['country_code'], - ); + ]; require_once 'payment_gateways/opayo/eme-opayo-util.php'; $crypt = SagepayUtil::encryptAes( SagepayUtil::arrayToQueryString( $query ), $opayo_pwd ); @@ -763,12 +763,12 @@ function eme_braintree_form( $item_name, $payment, $baseprice, $cur, $multi_book require_once 'payment_gateways/braintree/braintree-php-6.9.0/lib/Braintree.php'; $braintree_gateway = new Braintree\Gateway( - array( + [ 'environment' => $eme_braintree_env, 'merchantId' => $eme_braintree_merchant_id, 'publicKey' => $eme_braintree_public_key, 'privateKey' => $eme_braintree_private_key, - ) + ] ); $clientToken = $braintree_gateway->clientToken()->generate(); @@ -847,7 +847,7 @@ function eme_sumup_form( $item_name, $payment, $baseprice, $cur, $multi_booking $events_page_link = eme_get_events_page(); $payment_id = $payment['id']; $return_link = eme_payment_return_url( $payment, 'sumup' ); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'sumup_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'sumup_notification' ], $events_page_link ); if ( $payment['target'] == 'member' ) { $description = sprintf( __( "Member signup for '%s'", 'events-made-easy' ), $item_name ); @@ -878,12 +878,12 @@ function eme_sumup_form( $item_name, $payment, $baseprice, $cur, $multi_booking require_once 'payment_gateways/sumup/1.1.0/vendor/autoload.php'; try { $sumup = new \SumUp\SumUp( - array( + [ 'app_id' => get_option( 'eme_sumup_app_id' ), 'app_secret' => get_option( 'eme_sumup_app_secret' ), 'grant_type' => 'client_credentials', - 'scopes' => array( 'payments' ), - ) + 'scopes' => [ 'payments' ], + ] ); $accessToken = $sumup->getAccessToken(); $value = $accessToken->getValue(); @@ -1091,7 +1091,7 @@ function eme_instamojo_form( $item_name, $payment, $baseprice, $cur, $multi_book $events_page_link = eme_get_events_page(); $payment_id = $payment['id']; $return_link = eme_payment_return_url( $payment, 'instamojo' ); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'instamojo_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'instamojo_notification' ], $events_page_link ); if ( $payment['target'] == 'member' ) { $description = sprintf( __( "Member signup for '%s'", 'events-made-easy' ), $item_name ); @@ -1326,7 +1326,7 @@ function eme_legacypaypal_form( $item_name, $payment, $baseprice, $cur, $multi_b $payment_id = $payment['id']; $success_link = eme_payment_return_url( $payment, 0 ); $fail_link = eme_payment_return_url( $payment, 1 ); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'legacypaypal_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'legacypaypal_notification' ], $events_page_link ); if ( $payment['target'] == 'member' ) { $description = sprintf( __( "Member signup for '%s'", 'events-made-easy' ), $item_name ); @@ -1419,7 +1419,7 @@ function eme_mercadopago_form( $item_name, $payment, $baseprice, $cur, $multi_bo $events_page_link = eme_get_events_page(); $success_link = eme_payment_return_url( $payment, 0 ); $fail_link = eme_payment_return_url( $payment, 1 ); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'mercadopago_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'mercadopago_notification' ], $events_page_link ); require_once 'payment_gateways/mercadopago/2.4.9/vendor/autoload.php'; MercadoPago\SDK::setAccessToken( $eme_mercadopago_access_token ); @@ -1493,7 +1493,7 @@ function eme_mercadopago_form( $item_name, $payment, $baseprice, $cur, $multi_bo $item->quantity = 1; $item->currency_id = $cur; $item->unit_price = $price; - $preference->items = array( $item ); + $preference->items = [ $item ]; $preference->external_reference = $payment_id; $preference->notification_url = $notification_link; @@ -1620,13 +1620,13 @@ function eme_complete_sumup_transaction( $payment ) { require_once 'payment_gateways/sumup/1.1.0/vendor/autoload.php'; try { $sumup = new \SumUp\SumUp( - array( + [ 'app_id' => $eme_sumup_app_id, 'app_secret' => $eme_sumup_app_secret, 'grant_type' => 'client_credentials', - 'scopes' => array( 'payments', 'transactions.history' ), + 'scopes' => [ 'payments', 'transactions.history' ], //'scopes' => ['transactions.history'] - ) + ] ); $accessToken = $sumup->getAccessToken(); $value = $accessToken->getValue(); @@ -1734,9 +1734,9 @@ function eme_complete_fondy_transaction( $payment ) { \Cloudipsp\Configuration::setSecretKey( $eme_fondy_secret_key ); $order_id = "ep-{$payment['id']}"; - $data = array( + $data = [ 'order_id' => $order_id, - ); + ]; $orderStatus = \Cloudipsp\Order::status( $data ); $order = $orderStatus->getData(); @@ -1926,9 +1926,9 @@ function eme_notification_2co() { if ( $_POST['message_type'] == 'ORDER_CREATED' || $_POST['message_type'] == 'INVOICE_STATUS_CHANGED' ) { - $insMessage = array(); + $insMessage = []; foreach ( $_POST as $k => $v ) { - $insMessage[ $k ] = $v; + $insMessage[ eme_sanitize_request($k) ] = eme_sanitize_request($v); } $hashSid = $insMessage['vendor_id']; @@ -2039,12 +2039,12 @@ function eme_notification_sumup() { require_once 'payment_gateways/sumup/1.1.0/vendor/autoload.php'; try { $sumup = new \SumUp\SumUp( - array( + [ 'app_id' => $eme_sumup_app_id, 'app_secret' => $eme_sumup_app_secret, 'grant_type' => 'client_credentials', - 'scopes' => array( 'payments', 'transactions.history' ), - ) + 'scopes' => [ 'payments', 'transactions.history' ], + ] ); $accessToken = $sumup->getAccessToken(); $value = $accessToken->getValue(); @@ -2085,9 +2085,9 @@ function eme_notification_stripe() { // verify the signature try { $event = \Stripe\Webhook::constructEvent( - $payload, - $sig_header, - $webhook_secret + $payload, + $sig_header, + $webhook_secret ); } catch ( \UnexpectedValueException $e ) { // Invalid payload @@ -2114,8 +2114,8 @@ function eme_notification_fondy() { $gateway = 'fondy'; - $merchant_id = get_option( "eme_${gateway}_merchant_id" ); - $secret_key = get_option( "eme_${gateway}_secret_key" ); + $merchant_id = get_option( "eme_{$gateway}_merchant_id" ); + $secret_key = get_option( "eme_{$gateway}_secret_key" ); if ( ! $merchant_id || ! $secret_key ) { http_response_code( 500 ); exit; @@ -2150,7 +2150,7 @@ function eme_stripe_webhook() { } // do nothing if the events page is on localhost $events_page_link = eme_get_events_page(); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'stripe_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'stripe_notification' ], $events_page_link ); if ( strstr( $events_page_link, 'localhost' ) ) { update_option( 'eme_stripe_webhook_error', __( 'since this is a site running on localhost, no webhook will be created', 'events-made-easy' ) ); return; @@ -2162,7 +2162,7 @@ function eme_stripe_webhook() { // first check all webhooks, delete the one matching our url and recreate it, otherwise we can't get the secret $webhooks = null; try { - $webhooks = \Stripe\WebhookEndpoint::all( array( 'limit' => 100 ) ); + $webhooks = \Stripe\WebhookEndpoint::all( [ 'limit' => 100 ] ); if ( ! empty( $webhooks ) ) { foreach ( $webhooks->data as $webhook ) { $endpoint_id = $webhook->id; @@ -2180,10 +2180,10 @@ function eme_stripe_webhook() { update_option( 'eme_stripe_webhook_secret', '' ); try { $endpoint = \Stripe\WebhookEndpoint::create( - array( + [ 'url' => $notification_link, - 'enabled_events' => array( 'checkout.session.completed' ), - ) + 'enabled_events' => [ 'checkout.session.completed' ], + ] ); } catch ( \Stripe\Exception\InvalidRequestException $e ) { update_option( 'eme_stripe_webhook_error', $e->getMessage() ); @@ -2224,40 +2224,40 @@ function eme_charge_paypal() { // although mentioning items is not obligated, you need it or on the paypal window the amount and description won't show $request = new \PayPalCheckoutSdk\Orders\OrdersCreateRequest(); $request->prefer( 'return=representation' ); - $request->body = array( + $request->body = [ 'intent' => 'CAPTURE', - 'purchase_units' => array( - array( + 'purchase_units' => [ + [ 'reference_id' => $payment_id, 'description' => "$description", - 'amount' => array( + 'amount' => [ 'value' => "$price", 'currency_code' => "$cur", - 'breakdown' => array( - 'item_total' => array( + 'breakdown' => [ + 'item_total' => [ 'value' => "$price", 'currency_code' => "$cur", - ), - ), - ), - 'items' => array( - array( + ], + ], + ], + 'items' => [ + [ 'name' => "$description", 'description' => "$description", - 'unit_amount' => array( + 'unit_amount' => [ 'value' => "$price", 'currency_code' => "$cur", - ), + ], 'quantity' => '1', - ), - ), - ), - ), - 'application_context' => array( + ], + ], + ], + ], + 'application_context' => [ 'cancel_url' => $fail_link, 'return_url' => $success_link, - ), - ); + ], + ]; $url = ''; try { @@ -2318,27 +2318,27 @@ function eme_charge_stripe() { $payment_methods_arr = $payment_methods; } $stripe_session = \Stripe\Checkout\Session::create( - array( + [ 'payment_method_types' => $payment_methods_arr, - 'payment_intent_data' => array( 'description' => $description ), - 'line_items' => array( - array( - 'price_data' => array( + 'payment_intent_data' => [ 'description' => $description ], + 'line_items' => [ + [ + 'price_data' => [ 'currency' => strtolower( $cur ), 'unit_amount' => $price, - 'product_data' => array( + 'product_data' => [ 'name' => $item_name, 'description' => $description, - ), - ), + ], + ], 'quantity' => 1, - ), - ), + ], + ], 'mode' => 'payment', 'client_reference_id' => $payment_id, 'success_url' => $success_link, 'cancel_url' => $fail_link, - ) + ] ); $stripe_session_id = $stripe_session->id; @@ -2421,19 +2421,19 @@ function eme_charge_braintree() { die( 'The nonce was not generated correctly' ); } $braintree_gateway = new Braintree\Gateway( - array( + [ 'environment' => $eme_braintree_env, 'merchantId' => $eme_braintree_merchant_id, 'publicKey' => $eme_braintree_public_key, 'privateKey' => $eme_braintree_private_key, - ) + ] ); $result = $braintree_gateway->transaction()->sale( - array( + [ 'amount' => $price, 'paymentMethodNonce' => $_POST['braintree_nonce'], 'orderId' => $payment_id, - ) + ] ); if ( $result->success ) { $transaction = $result->transaction; @@ -2463,7 +2463,7 @@ function eme_charge_instamojo() { $return_link = eme_payment_return_url( $payment, 'instamojo' ); $fail_link = eme_payment_return_url( $payment, 1 ); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'instamojo_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'instamojo_notification' ], $events_page_link ); // no cheating if ( ! wp_verify_nonce( eme_sanitize_request($_POST['eme_instamojo_nonce']), $price ) ) { @@ -2480,13 +2480,13 @@ function eme_charge_instamojo() { } try { $instamojo_payment = $api->paymentRequestCreate( - array( + [ 'purpose' => $description, 'amount' => "$price", 'redirect_url' => $return_link, 'webhook' => $notification_link, - ) + ] ); $url = $instamojo_payment['longurl']; } catch ( Exception $e ) { @@ -2522,9 +2522,9 @@ function eme_charge_mercadopago() { require_once 'payment_gateways/mercadopago/2.4.9/vendor/autoload.php'; MercadoPago\SDK::setAccessToken( $eme_mercadopago_access_token ); - $filter = array( + $filter = [ 'external_reference' => $payment_id, - ); + ]; $paid_amount = 0; $mercadopago_payments = MercadoPago\Payment::search( $filter ); foreach ( $mercadopago_payments as $mercadopago_payment ) { @@ -2548,8 +2548,8 @@ function eme_charge_mercadopago() { function eme_charge_fondy() { $gateway = 'fondy'; - $merchant_id = get_option( "eme_${gateway}_merchant_id" ); - $secret_key = get_option( "eme_${gateway}_secret_key" ); + $merchant_id = get_option( "eme_{$gateway}_merchant_id" ); + $secret_key = get_option( "eme_{$gateway}_secret_key" ); if ( ! $merchant_id || ! $secret_key ) { return; } @@ -2562,11 +2562,11 @@ function eme_charge_fondy() { $payment = eme_get_payment( $payment_id ); $events_page_link = eme_get_events_page(); - $notification_link = add_query_arg( array( 'eme_eventAction' => "${gateway}_notification" ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => "{$gateway}_notification" ], $events_page_link ); $success_link = eme_payment_return_url( $payment, 0 ); $fail_link = eme_payment_return_url( $payment, 1 ); - if ( ! wp_verify_nonce( eme_sanitize_request($_POST[ "eme_${gateway}_nonce" ]), "$price$cur" ) ) { + if ( ! wp_verify_nonce( eme_sanitize_request($_POST[ "eme_{$gateway}_nonce" ]), "$price$cur" ) ) { header( "Location: $fail_link" ); exit; } @@ -2575,16 +2575,16 @@ function eme_charge_fondy() { \Cloudipsp\Configuration::setMerchantId( $merchant_id ); \Cloudipsp\Configuration::setSecretKey( $secret_key ); - $data = array( + $data = [ 'order_desc' => $description, 'amount' => $price, 'currency' => $cur, 'server_callback_url' => $notification_link, 'response_url' => $success_link, - 'merchant_data' => array( + 'merchant_data' => [ 'payment_id' => $payment_id, - ), - ); + ], + ]; try { $response = \Cloudipsp\Checkout::url( $data ); @@ -2617,13 +2617,13 @@ function eme_refund_booking_paypal( $booking ) { if ( ! empty( $event ) ) { $cur = $event['currency']; $request = new \PayPalCheckoutSdk\Payments\CapturesRefundRequest( $booking['pg_pid'] ); - $request->body = array( + $request->body = [ 'amount' => - array( + [ 'value' => $price, 'currency_code' => $cur, - ), - ); + ], + ]; try { $response = $client->execute( $request ); return true; @@ -2680,11 +2680,11 @@ function eme_refund_booking_instamojo( $booking ) { } try { $response = $api->refundCreate( - array( + [ 'payment_id' => $booking['pg_pid'], 'type' => 'QFL', 'body' => __( 'Booking refunded', 'events-made-easy' ), - ) + ] ); return true; } catch ( Exception $e ) { @@ -2696,8 +2696,8 @@ function eme_refund_booking_instamojo( $booking ) { function eme_refund_booking_fondy( $booking ) { $gateway = 'fondy'; - $merchant_id = get_option( "eme_${gateway}_merchant_id" ); - $secret_key = get_option( "eme_${gateway}_secret_key" ); + $merchant_id = get_option( "eme_{$gateway}_merchant_id" ); + $secret_key = get_option( "eme_{$gateway}_secret_key" ); if ( ! $merchant_id || ! $secret_key ) { return; } @@ -2707,17 +2707,17 @@ function eme_refund_booking_fondy( $booking ) { \Cloudipsp\Configuration::setSecretKey( $secret_key ); try { - $order_data = array( + $order_data = [ 'order_id' => $booking['pg_pid'], - ); + ]; $orderStatus = \Cloudipsp\Order::status( $order_data ); $order = $orderStatus->getData(); - $refund_data = array( + $refund_data = [ 'order_id' => $booking['pg_pid'], 'amount' => $order['amount'], 'currency' => $order['currency'], - ); + ]; $response = \Cloudipsp\Order::reverse( $refund_data ); return $response->isReversed(); } catch ( \Exception $e ) { @@ -2744,9 +2744,9 @@ function eme_refund_booking_stripe( $booking ) { return; } $re = \Stripe\Refund::create( - array( + [ 'payment_intent' => $stripe_pi_id, - ) + ] ); return true; } @@ -2764,12 +2764,12 @@ function eme_refund_booking_braintree( $booking ) { require_once 'payment_gateways/braintree/braintree-php-6.9.0/lib/Braintree.php'; $braintree_gateway = new Braintree\Gateway( - array( + [ 'environment' => $eme_braintree_env, 'merchantId' => $eme_braintree_merchant_id, 'publicKey' => $eme_braintree_public_key, 'privateKey' => $eme_braintree_private_key, - ) + ] ); $transaction_id = $booking['pg_pid']; $result = $braintree_gateway->transaction()->refund( $transaction_id ); @@ -2791,7 +2791,7 @@ function eme_charge_mollie() { $return_link = eme_payment_return_url( $payment, 'mollie' ); $fail_link = eme_payment_return_url( $payment, 'mollie' ); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'mollie_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'mollie_notification' ], $events_page_link ); // no cheating if ( ! wp_verify_nonce( eme_sanitize_request($_POST['eme_mollie_nonce']), "$price$cur" ) ) { @@ -2809,18 +2809,18 @@ function eme_charge_mollie() { try { $mollie->setApiKey( $api_key ); $mollie_payment = $mollie->payments->create( - array( - 'amount' => array( + [ + 'amount' => [ 'currency' => $cur, 'value' => sprintf( '%01.2f', $price ), - ), + ], 'description' => $description, 'redirectUrl' => $return_link, 'webhookUrl' => $notification_link, - 'metadata' => array( + 'metadata' => [ 'payment_id' => $payment_id, - ), - ) + ], + ] ); $url = $mollie_payment->getCheckoutUrl(); } catch ( \Mollie\Api\Exceptions\ApiException $e ) { @@ -2877,14 +2877,14 @@ function eme_charge_payconiq() { $payment = eme_get_payment( $payment_id ); $gateway = 'payconiq'; - $api_key = get_option( "eme_${gateway}_api_key" ); + $api_key = get_option( "eme_{$gateway}_api_key" ); if ( ! $api_key ) { return; } $return_link = eme_payment_return_url( $payment, $gateway ); $fail_link = eme_payment_return_url( $payment, $gateway ); - $notification_link = add_query_arg( array( 'eme_eventAction' => 'payconiq_notification' ), $events_page_link ); + $notification_link = add_query_arg( [ 'eme_eventAction' => 'payconiq_notification' ], $events_page_link ); // no cheating if ( ! wp_verify_nonce( eme_sanitize_request($_POST['eme_payconiq_nonce']), "$price$cur" ) ) { @@ -2922,8 +2922,8 @@ function eme_charge_payconiq() { function eme_notification_payconiq( $payconiq_paymentid = 0 ) { $gateway = 'payconiq'; - $api_key = get_option( "eme_${gateway}_api_key" ); - $merchant_id = get_option( "eme_${gateway}_merchant_id" ); + $api_key = get_option( "eme_{$gateway}_api_key" ); + $merchant_id = get_option( "eme_{$gateway}_merchant_id" ); if ( ! $api_key ) { return; } @@ -3001,12 +3001,12 @@ function eme_refund_booking_mollie( $booking ) { $cur = $event['currency']; if ( $mollie_payment->canBeRefunded() && $mollie_payment->amountRemaining->currency === $cur && $mollie_payment->amountRemaining->value >= $price ) { $refund = $mollie_payment->refund( - array( - 'amount' => array( + [ + 'amount' => [ 'currency' => "$cur", 'value' => "$price", - ), - ) + ], + ] ); return true; } else { @@ -3060,7 +3060,7 @@ function eme_notification_opayo() { } function eme_get_configured_pgs() { - $pgs = array(); + $pgs = []; if ( ! empty( get_option( 'eme_paypal_clientid' ) ) ) { $pgs[] = 'paypal'; } @@ -3198,7 +3198,7 @@ function eme_create_member_payment( $member_id ) { $payments_table = $eme_db_prefix . PAYMENTS_TBNAME; $members_table = $eme_db_prefix . MEMBERS_TBNAME; $payment_id = false; - $payment = array(); + $payment = []; $payment['random_id'] = eme_random_id(); $payment['target'] = 'member'; $payment['creation_date'] = current_time( 'mysql', false ); @@ -3223,7 +3223,7 @@ function eme_create_payment( $booking_ids ) { } $payment_id = false; - $payment = array(); + $payment = []; $payment['random_id'] = eme_random_id(); $payment['target'] = 'booking'; $payment['creation_date'] = current_time( 'mysql', false ); @@ -3231,8 +3231,8 @@ function eme_create_payment( $booking_ids ) { $payment_id = $wpdb->insert_id; $booking_ids_arr = explode( ',', $booking_ids ); foreach ( $booking_ids_arr as $booking_id ) { - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking_id; $fields['unique_nbr'] = eme_unique_nbr( $payment_id ); $fields['payment_id'] = $payment_id; @@ -3588,10 +3588,10 @@ function eme_cancel_payment_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $form_html = __( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -3599,10 +3599,10 @@ function eme_cancel_payment_ajax() { if ( ! isset( $_POST['eme_frontend_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), "cancel payment $payment_randomid" ) ) { $form_html = __( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -3611,10 +3611,10 @@ function eme_cancel_payment_ajax() { if ( ! eme_check_hcaptcha() ) { $form_html = __( 'Please check the hCaptcha box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -3622,10 +3622,10 @@ function eme_cancel_payment_ajax() { if ( ! eme_check_recaptcha() ) { $form_html = __( 'Please check the Google reCAPTCHA box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -3633,10 +3633,10 @@ function eme_cancel_payment_ajax() { if ( ! eme_check_captcha( 1 ) ) { $form_html = __( 'You entered an incorrect code', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -3654,10 +3654,10 @@ function eme_cancel_payment_ajax() { $form_html = __( 'Booking already cancelled', 'events-made-easy' ); } echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -3703,10 +3703,10 @@ function eme_cancel_payment_ajax() { // don't delete the linked payment, since the booking is in trash and can still be restored // eme_delete_payment($booking['payment_id']); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } diff --git a/eme-people.php b/eme-people.php index e2eb30ac..73aa78d3 100644 --- a/eme-people.php +++ b/eme-people.php @@ -5,7 +5,7 @@ } function eme_new_person() { - $person = array( + $person = [ 'lastname' => '', 'firstname' => '', 'email' => '', @@ -28,21 +28,21 @@ function eme_new_person() { 'massmail' => get_option( 'eme_people_massmail' ), 'newsletter' => get_option( 'eme_people_newsletter' ), 'gdpr' => 0, - 'properties' => array(), - ); + 'properties' => [], + ]; $person['properties'] = eme_init_person_props( $person['properties'] ); return $person; } function eme_new_group() { - $group = array( + $group = [ 'name' => '', 'type' => 'static', 'public' => 0, 'description' => '', 'email' => '', - 'search_terms' => array(), - ); + 'search_terms' => [], + ]; return $group; } @@ -69,7 +69,7 @@ function eme_people_page() { } } elseif ( isset( $_POST['eme_admin_action'] ) && eme_sanitize_request($_POST['eme_admin_action']) == 'do_addperson' ) { if ( current_user_can( get_option( 'eme_cap_edit_people' ) ) ) { - list($add_update_message,$person_id) = eme_add_update_person_from_backend(); + [$add_update_message, $person_id] = eme_add_update_person_from_backend(); if ( $person_id ) { $message = esc_html__( 'Person added', 'events-made-easy' ); if ( get_option( 'eme_stay_on_edit_page' ) ) { @@ -89,7 +89,7 @@ function eme_people_page() { $person_id = intval( $_POST['person_id'] ); $wp_id = eme_get_wpid_by_personid( $person_id ); if ( current_user_can( get_option( 'eme_cap_edit_people' ) ) || ( current_user_can( get_option( 'eme_cap_author_person' ) ) && $wp_id == $current_userid ) ) { - list($add_update_message,$person_id) = eme_add_update_person_from_backend( $person_id ); + [$add_update_message, $person_id] = eme_add_update_person_from_backend( $person_id ); if ( $person_id ) { $message = esc_html__( 'Person updated', 'events-made-easy' ); } else { @@ -182,13 +182,13 @@ function eme_groups_page() { function eme_person_shortcode( $atts ) { eme_enqueue_frontend(); $atts = shortcode_atts( - array( + [ 'person_id' => 0, 'template_id' => 0, - ), - $atts + ], + $atts ); - $person = array(); + $person = []; // the GET param prid (person randomid) overrides person_id if present if ( isset( $_GET['prid'] ) && isset( $_GET['eme_frontend_nonce'] ) && wp_verify_nonce( eme_sanitize_request($_GET['eme_frontend_nonce']), 'eme_frontend' ) ) { $random_id = eme_sanitize_request( $_GET['prid'] ); @@ -211,14 +211,14 @@ function eme_person_shortcode( $atts ) { function eme_people_shortcode( $atts ) { eme_enqueue_frontend(); $atts = shortcode_atts( - array( + [ 'group_id' => 0, 'order' => 'ASC', 'template_id' => 0, 'template_id_header' => 0, 'template_id_footer' => 0, - ), - $atts + ], + $atts ); if ( ! empty( $atts['group_id'] ) ) { @@ -504,7 +504,7 @@ function eme_replace_people_placeholders( $format, $person, $target = 'html', $l } } elseif ( preg_match( '/#_IMAGE$/', $result ) ) { if ( ! empty( $person['properties']['image_id'] ) ) { - $replacement = wp_get_attachment_image( $person['properties']['image_id'], 'full', 0, array( 'class' => 'eme_person_image' ) ); + $replacement = wp_get_attachment_image( $person['properties']['image_id'], 'full', 0, [ 'class' => 'eme_person_image' ] ); if ( $target == 'html' ) { $replacement = apply_filters( 'eme_general', $replacement ); } elseif ( $target == 'rss' ) { @@ -522,7 +522,7 @@ function eme_replace_people_placeholders( $format, $person, $target = 'html', $l } } elseif ( preg_match( '/#_IMAGETHUMB$/', $result ) ) { if ( ! empty( $person['properties']['image_id'] ) ) { - $replacement = wp_get_attachment_image( $person['properties']['image_id'], get_option( 'eme_thumbnail_size' ), 0, array( 'class' => 'eme_person_image' ) ); + $replacement = wp_get_attachment_image( $person['properties']['image_id'], get_option( 'eme_thumbnail_size' ), 0, [ 'class' => 'eme_person_image' ] ); if ( $target == 'html' ) { $replacement = apply_filters( 'eme_general', $replacement ); } elseif ( $target == 'rss' ) { @@ -540,7 +540,7 @@ function eme_replace_people_placeholders( $format, $person, $target = 'html', $l } } elseif ( preg_match( '/#_IMAGETHUMB\{(.+)\}/', $result, $matches ) ) { if ( ! empty( $person['properties']['image_id'] ) ) { - $replacement = wp_get_attachment_image( $person['properties']['image_id'], $matches[1], 0, array( 'class' => 'eme_person_image' ) ); + $replacement = wp_get_attachment_image( $person['properties']['image_id'], $matches[1], 0, [ 'class' => 'eme_person_image' ] ); if ( $target == 'html' ) { $replacement = apply_filters( 'eme_general', $replacement ); } elseif ( $target == 'rss' ) { @@ -581,7 +581,7 @@ function eme_replace_people_placeholders( $format, $person, $target = 'html', $l } } elseif ( preg_match( '/#_PERSONAL_FILES/', $result ) ) { $files = eme_get_uploaded_files( $person['person_id'], 'people' ); - $res_files = array(); + $res_files = []; foreach ( $files as $file ) { if ( $target == 'html' ) { $res_files[] = eme_get_uploaded_file_html( $file ); @@ -743,7 +743,7 @@ function eme_import_csv_people() { $answers_table = $eme_db_prefix . ANSWERS_TBNAME; //validate whether uploaded file is a csv file - $csvMimes = array( 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ); + $csvMimes = [ 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ]; if ( empty( $_FILES['eme_csv']['name'] ) || ! in_array( $_FILES['eme_csv']['type'], $csvMimes ) ) { return sprintf( esc_html__( 'No CSV file detected: %s', 'events-made-easy' ), $_FILES['eme_csv']['type'] ); } @@ -786,7 +786,7 @@ function eme_import_csv_people() { if ( ! in_array( 'lastname', $headers ) || ! in_array( 'firstname', $headers ) || ! in_array( 'email', $headers ) ) { $result = esc_html__( 'Not all required fields present.', 'events-made-easy' ); } else { - $empty_props = array(); + $empty_props = []; $empty_props = eme_init_person_props( $empty_props ); // now loop over the rest while ( ( $row = fgetcsv( $handle, 0, $delimiter, $enclosure ) ) !== false ) { @@ -811,7 +811,7 @@ function eme_import_csv_people() { if ( preg_match( '/^prop_(.*)$/', $key, $matches ) ) { $prop = $matches[1]; if ( ! isset( $line['properties'] ) ) { - $line['properties'] = array(); + $line['properties'] = []; } if ( array_key_exists( $prop, $empty_props ) ) { $line['properties'][ $prop ] = $value; @@ -916,7 +916,7 @@ function eme_csv_booking_report( $event_id ) { $line = apply_filters( 'eme_csv_header_filter', $event ); eme_fputcsv( $out, $line, $separator ); } - $line = array(); + $line = []; $line[] = __( 'ID', 'events-made-easy' ); $line[] = __( 'Last name', 'events-made-easy' ); $line[] = __( 'First name', 'events-made-easy' ); @@ -979,7 +979,7 @@ function eme_csv_booking_report( $event_id ) { $person = eme_new_person(); } $person_answers = eme_get_person_answers( $booking['person_id'] ); - $line = array(); + $line = []; $status_string = ''; if ( $booking['waitinglist'] ) { $status_string = __( 'On waiting list', 'events-made-easy' ); @@ -1047,7 +1047,7 @@ function eme_csv_booking_report( $event_id ) { } $line[] = $localized_booking_datetime; - $discount_names = array(); + $discount_names = []; if ( $booking['dgroupid'] ) { $dgroup = eme_get_discountgroup( $booking['dgroupid'] ); if ( $dgroup && isset( $dgroup['name'] ) ) { @@ -1550,7 +1550,7 @@ function eme_person_verify_layout() { esc_html_e( 'The table below shows the people that have identical emails while you require a unique email per person', 'events-made-easy' ); print '
    '; esc_html_e( 'Please correct these errors: all EME people should have a unique email.', 'events-made-easy' ); - $people = array(); + $people = []; foreach ( $emails_arr as $email ) { $person_ids_arr = eme_get_personids_by_email( $email ); $person_ids = join( ',', $person_ids_arr ); @@ -1587,7 +1587,7 @@ function eme_person_verify_layout() { esc_like( trim( $search_terms['search_person'] ) ) ) : ''; $where = ''; - $where_arr = array(); + $where_arr = []; // if the person is not allowed to manage all people, show only himself if ( ! current_user_can( get_option( 'eme_cap_list_people' ) ) ) { @@ -1707,7 +1707,7 @@ function eme_get_sql_people_searchfields( $search_terms, $start = 0, $pagesize = // we need this GROUP_CONCAT so we can sort on those fields too (otherwise the columns FIELD_* don't exist in the returning sql $group_concat_sql = ''; - $field_ids_arr = array(); + $field_ids_arr = []; foreach ( $formfields_searchable as $formfield ) { $field_id = $formfield['field_id']; $field_ids_arr[] = $field_id; @@ -1900,9 +1900,9 @@ function eme_manage_people_layout( $message = '' ) { eme_get_country_name( $country_code ) ); + $country_arr = [ $country_code => eme_get_country_name( $country_code ) ]; } else { - $country_arr = array(); + $country_arr = []; } if ( ! empty( $person['state_code'] ) && ! empty( $person['country_code'] ) ) { $country_code = $person['country_code']; $state_code = $person['state_code']; - $state_arr = array( $state_code => eme_get_state_name( $state_code, $country_code ) ); + $state_arr = [ $state_code => eme_get_state_name( $state_code, $country_code ) ]; } else { - $state_arr = array(); + $state_arr = []; } if ( ! empty( $person['related_person_id'] ) ) { $related_person = eme_get_person( $person['related_person_id'] ); @@ -2149,12 +2149,12 @@ function eme_person_edit_layout( $person_id = 0, $message = '' ) { $used_wp_ids = eme_get_used_wpids( $person['wp_id'] ); $exclude = join( ',', $used_wp_ids ); wp_dropdown_users( - array( + [ 'name' => 'wp_id', 'show_option_none' => ' ', 'selected' => $person['wp_id'], 'exclude' => $exclude, - ) + ] ); ?>
    @@ -2196,8 +2196,8 @@ function eme_person_edit_layout( $person_id = 0, $message = '' ) { function eme_group_edit_layout( $group_id = 0, $message = '' ) { global $plugin_page,$eme_plugin_url; - $grouppersons = array(); - $mygroups = array(); + $grouppersons = []; + $mygroups = []; if ( ! $group_id ) { $action = 'add'; $group = eme_new_group(); @@ -2516,17 +2516,17 @@ function eme_find_persons_double_wp() { function eme_count_persons_with_wp_id( $wp_id ) { global $wpdb,$eme_db_prefix; $people_table = $eme_db_prefix . PEOPLE_TBNAME; - $sql = $wpdb->prepare( "SELECT COUNT(*) FROM $people_table WHERE wp_id = %d AND status= %d ", $wp_id, EME_PEOPLE_STATUS_ACTIVE); + $sql = $wpdb->prepare( "SELECT COUNT(*) FROM $people_table WHERE wp_id = %d AND status= %d ", $wp_id, EME_PEOPLE_STATUS_ACTIVE); return $wpdb->get_var( $sql ); } function eme_get_people_by_ids( $ids ) { global $wpdb,$eme_db_prefix; $people_table = $eme_db_prefix . PEOPLE_TBNAME; - $ids_arr = explode(',',$ids); + $ids_arr = explode(',', $ids); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("SELECT * FROM $people_table WHERE person_id IN ($commaDelimitedPlaceholders) AND status= %d ORDER BY person_id",array_merge($ids_arr,array(EME_PEOPLE_STATUS_ACTIVE))); + $sql = $wpdb->prepare("SELECT * FROM $people_table WHERE person_id IN ($commaDelimitedPlaceholders) AND status= %d ORDER BY person_id", array_merge($ids_arr, [EME_PEOPLE_STATUS_ACTIVE])); return $wpdb->get_results( $sql, ARRAY_A ); } else { return false; @@ -2536,10 +2536,10 @@ function eme_get_people_by_ids( $ids ) { function eme_get_people_by_wp_ids( $wp_ids ) { global $wpdb,$eme_db_prefix; $people_table = $eme_db_prefix . PEOPLE_TBNAME; - $ids_arr = explode(',',$wp_ids); + $ids_arr = explode(',', $wp_ids); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("SELECT * FROM $people_table WHERE wp_id IN ($commaDelimitedPlaceholders) AND status= %d ORDER BY wp_id",array_merge($ids_arr,array(EME_PEOPLE_STATUS_ACTIVE))); + $sql = $wpdb->prepare("SELECT * FROM $people_table WHERE wp_id IN ($commaDelimitedPlaceholders) AND status= %d ORDER BY wp_id", array_merge($ids_arr, [EME_PEOPLE_STATUS_ACTIVE])); return $wpdb->get_results( $sql, ARRAY_A ); } } @@ -2554,7 +2554,7 @@ function eme_get_person_by_wp_id( $wp_id, $use_wp_info = 1 ) { $person = wp_cache_get( "eme_person_wpid $wp_id" ); if ( $person === false ) { - $sql = $wpdb->prepare( "SELECT * FROM $people_table WHERE wp_id = %d AND status=%d",$wp_id , EME_PEOPLE_STATUS_ACTIVE); + $sql = $wpdb->prepare( "SELECT * FROM $people_table WHERE wp_id = %d AND status=%d", $wp_id, EME_PEOPLE_STATUS_ACTIVE); $lines = $wpdb->get_results( $sql, ARRAY_A ); } else { return $person; @@ -2641,10 +2641,10 @@ function eme_trash_people( $person_ids ) { eme_delete_person_groups( $person_ids ); $modif_date = current_time( 'mysql', false ); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("UPDATE $people_table SET status=%d, modif_date=%s, wp_id=0 WHERE person_id IN ($commaDelimitedPlaceholders)",array_merge(array(EME_PEOPLE_STATUS_TRASH,$modif_date),$ids_arr)); + $sql = $wpdb->prepare("UPDATE $people_table SET status=%d, modif_date=%s, wp_id=0 WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge([EME_PEOPLE_STATUS_TRASH,$modif_date], $ids_arr)); $wpdb->query( $sql ); // break the family relationship - $sql = $wpdb->prepare("UPDATE $people_table SET related_person_id=0 WHERE related_person_id IN ($commaDelimitedPlaceholders)",$ids_arr); + $sql = $wpdb->prepare("UPDATE $people_table SET related_person_id=0 WHERE related_person_id IN ($commaDelimitedPlaceholders)", $ids_arr); $wpdb->query( $sql ); } @@ -2738,7 +2738,7 @@ function eme_untrash_people( $person_ids ) { $ids_arr = explode( ',', $person_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "UPDATE $people_table SET status=%d WHERE person_id IN ($commaDelimitedPlaceholders)",array_merge(array(EME_PEOPLE_STATUS_ACTIVE),$ids_arr)); + $sql = $wpdb->prepare( "UPDATE $people_table SET status=%d WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge([EME_PEOPLE_STATUS_ACTIVE], $ids_arr)); $wpdb->query( $sql ); } } @@ -2780,7 +2780,7 @@ function eme_delete_people( $person_ids ) { $ids_arr = explode( ',', $person_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "DELETE FROM $people_table WHERE person_id IN ($commaDelimitedPlaceholders)",$ids_arr); + $sql = $wpdb->prepare( "DELETE FROM $people_table WHERE person_id IN ($commaDelimitedPlaceholders)", $ids_arr); $wpdb->query( $sql ); foreach ( $ids_arr as $person_id ) { eme_delete_uploaded_files( $person_id, 'people' ); @@ -2833,7 +2833,7 @@ function eme_get_public_groups( $group_ids = '' ) { $ids_arr = explode( ',', $group_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "SELECT * FROM $table WHERE public=1 AND type='static' AND group_id IN ($commaDelimitedPlaceholders) ORDER BY name",$ids_arr); + $sql = $wpdb->prepare( "SELECT * FROM $table WHERE public=1 AND type='static' AND group_id IN ($commaDelimitedPlaceholders) ORDER BY name", $ids_arr); } else { return false; } @@ -2867,7 +2867,7 @@ function eme_groups_exists( $ids_arr ) { $table = $eme_db_prefix . GROUPS_TBNAME; if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM $table WHERE group_id IN ($commaDelimitedPlaceholders)",$ids_arr); + $sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM $table WHERE group_id IN ($commaDelimitedPlaceholders)", $ids_arr); return $wpdb->get_col( $sql ); } else { return false; @@ -2923,7 +2923,7 @@ function eme_add_persongroups( $person_id, $group_ids, $public = 0 ) { $current_group_ids = eme_get_persongroup_ids( $person_id ); // make sure it is an array if ( ! is_array( $group_ids ) ) { - $group_ids = array( $group_ids ); + $group_ids = [ $group_ids ]; } $res = true; @@ -2966,7 +2966,7 @@ function eme_get_person_by_email_in_groups( $email, $group_ids ) { $ids_arr = explode( ',', $group_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "SELECT p.person_id FROM $people_table p LEFT JOIN $usergroups_table u ON u.person_id=p.person_id WHERE p.email=%s AND u.group_id IN ($commaDelimitedPlaceholders) LIMIT 1", array_merge(array($email),$ids_arr) ); + $sql = $wpdb->prepare( "SELECT p.person_id FROM $people_table p LEFT JOIN $usergroups_table u ON u.person_id=p.person_id WHERE p.email=%s AND u.group_id IN ($commaDelimitedPlaceholders) LIMIT 1", array_merge([$email], $ids_arr) ); } else { return 0; } @@ -3036,9 +3036,9 @@ function eme_delete_groups( $group_ids ) { $ids_arr = explode( ',', $group_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("DELETE FROM $groups_table WHERE group_id IN ($commaDelimitedPlaceholders)",$ids_arr); + $sql = $wpdb->prepare("DELETE FROM $groups_table WHERE group_id IN ($commaDelimitedPlaceholders)", $ids_arr); $wpdb->query( $sql ); - $sql = $wpdb->prepare("DELETE FROM $usergroups_table WHERE group_id IN ($commaDelimitedPlaceholders)",$ids_arr); + $sql = $wpdb->prepare("DELETE FROM $usergroups_table WHERE group_id IN ($commaDelimitedPlaceholders)", $ids_arr); $wpdb->query( $sql ); } } @@ -3049,7 +3049,7 @@ function eme_get_persons( $person_ids = '', $extra_search = '', $limit = '', $or $answers_table = $eme_db_prefix . ANSWERS_TBNAME; $where = ''; - $where_arr = array(); + $where_arr = []; $where_arr[] = 'status=' . EME_PEOPLE_STATUS_ACTIVE; if ( ! empty( $person_ids ) && eme_array_integers( $person_ids ) ) { $tmp_ids = join( ',', $person_ids ); @@ -3073,7 +3073,7 @@ function eme_get_persons( $person_ids = '', $extra_search = '', $limit = '', $or $orderby = "ORDER BY lastname $order,firstname $order,person_id $order"; } } elseif ( ! eme_is_empty_string( $order ) && preg_match( '/^[\w_\-\, ]+$/', $order ) ) { - $order_arr = array(); + $order_arr = []; if ( preg_match( '/^[\w_\-\, ]+$/', $order ) ) { $order_tmp_arr = explode( ',', $order ); foreach ( $order_tmp_arr as $order_ell ) { @@ -3136,14 +3136,14 @@ function eme_get_allmail_person_ids() { function eme_get_newsletter_person_ids() { global $wpdb,$eme_db_prefix; $people_table = $eme_db_prefix . PEOPLE_TBNAME; - $sql = $wpdb->prepare("SELECT person_id FROM $people_table WHERE status=%d AND massmail=1 AND newsletter=1 AND email<>'' GROUP BY email",EME_PEOPLE_STATUS_ACTIVE); + $sql = $wpdb->prepare("SELECT person_id FROM $people_table WHERE status=%d AND massmail=1 AND newsletter=1 AND email<>'' GROUP BY email", EME_PEOPLE_STATUS_ACTIVE); return $wpdb->get_col( $sql ); } function eme_get_massmail_person_ids() { global $wpdb,$eme_db_prefix; $people_table = $eme_db_prefix . PEOPLE_TBNAME; - $sql = $wpdb->prepare("SELECT person_id FROM $people_table WHERE status=%d AND massmail=1 AND email<>'' GROUP BY email",EME_PEOPLE_STATUS_ACTIVE); + $sql = $wpdb->prepare("SELECT person_id FROM $people_table WHERE status=%d AND massmail=1 AND email<>'' GROUP BY email", EME_PEOPLE_STATUS_ACTIVE); return $wpdb->get_col( $sql ); } @@ -3161,13 +3161,13 @@ function eme_get_groups_person_massemails( $group_ids ) { $static_groupids = $wpdb->get_col( $sql ); // for static groups we look at the massmail option, for dynamic groups not - $res = array(); + $res = []; if ( ! empty( $static_groupids ) && eme_array_integers( $static_groupids ) ) { $commaDelimitedPlaceholders2 = implode(',', array_fill(0, count($static_groupids), '%d')); - $sql = $wpdb->prepare("SELECT people.lastname, people.firstname, people.email FROM $people_table AS people LEFT JOIN $usergroups_table AS ugroups ON people.person_id=ugroups.person_id WHERE people.status=%d AND people.massmail=1 AND people.email<>'' AND ugroups.group_id IN ($commaDelimitedPlaceholders2) GROUP BY people.email", array_merge(array(EME_PEOPLE_STATUS_ACTIVE),$static_groupids)); + $sql = $wpdb->prepare("SELECT people.lastname, people.firstname, people.email FROM $people_table AS people LEFT JOIN $usergroups_table AS ugroups ON people.person_id=ugroups.person_id WHERE people.status=%d AND people.massmail=1 AND people.email<>'' AND ugroups.group_id IN ($commaDelimitedPlaceholders2) GROUP BY people.email", array_merge([EME_PEOPLE_STATUS_ACTIVE], $static_groupids)); $res = $wpdb->get_results( $sql, ARRAY_A ); } - $emails_seen = array(); + $emails_seen = []; foreach ( $res as $entry ) { $email = $entry['email']; if ( ! empty( $email ) ) { @@ -3228,10 +3228,10 @@ function eme_get_groups_person_ids( $group_ids, $extra_sql = '' ) { if ( ! empty( $static_groupids ) && eme_array_integers($static_groupids)) { $commaDelimitedPlaceholders2 = implode(',', array_fill(0, count($static_groupids), '%d')); - $sql = $wpdb->prepare( "SELECT people.person_id FROM $people_table AS people LEFT JOIN $usergroups_table AS ugroups ON people.person_id=ugroups.person_id WHERE people.status=%d AND ugroups.group_id IN ($commaDelimitedPlaceholders2) $extra_sql", array_merge(array(EME_PEOPLE_STATUS_ACTIVE),$static_groupids)); + $sql = $wpdb->prepare( "SELECT people.person_id FROM $people_table AS people LEFT JOIN $usergroups_table AS ugroups ON people.person_id=ugroups.person_id WHERE people.status=%d AND ugroups.group_id IN ($commaDelimitedPlaceholders2) $extra_sql", array_merge([EME_PEOPLE_STATUS_ACTIVE], $static_groupids)); $res = $wpdb->get_col( $sql ); } else { - $res = array(); + $res = []; } if ( ! eme_array_integers( $groups_arr ) ) { @@ -3272,9 +3272,9 @@ function eme_get_groups_member_ids( $group_ids ) { return false; } $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("SELECT * FROM $groups_table WHERE group_id IN ($commaDelimitedPlaceholders) AND type = 'dynamic_members'",$ids_arr); + $sql = $wpdb->prepare("SELECT * FROM $groups_table WHERE group_id IN ($commaDelimitedPlaceholders) AND type = 'dynamic_members'", $ids_arr); $dynamic_groups = $wpdb->get_results( $sql, ARRAY_A ); - $res = array(); + $res = []; foreach ( $dynamic_groups as $dynamic_group ) { if ( ! empty( $dynamic_group['search_terms'] ) ) { $search_terms = eme_unserialize( $dynamic_group['search_terms'] ); @@ -3297,7 +3297,7 @@ function eme_get_memberships_member_ids( $membership_ids ) { return false; } $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("SELECT members.member_id FROM $people_table AS people LEFT JOIN $members_table AS members ON people.person_id=members.person_id WHERE people.status=%d.AND members.status IN (%d,%d) AND members.membership_id IN ($commaDelimitedPlaceholders) GROUP BY people.email",array_merge(array(EME_PEOPLE_STATUS_ACTIVE,EME_MEMBER_STATUS_ACTIVE,EME_MEMBER_STATUS_GRACE),$ids_arr)); + $sql = $wpdb->prepare("SELECT members.member_id FROM $people_table AS people LEFT JOIN $members_table AS members ON people.person_id=members.person_id WHERE people.status=%d.AND members.status IN (%d,%d) AND members.membership_id IN ($commaDelimitedPlaceholders) GROUP BY people.email", array_merge([EME_PEOPLE_STATUS_ACTIVE,EME_MEMBER_STATUS_ACTIVE,EME_MEMBER_STATUS_GRACE], $ids_arr)); return $wpdb->get_col( $sql ); } @@ -3317,7 +3317,7 @@ function eme_db_insert_person( $line ) { // some properties validation: only image_id as int is allowed $props = eme_unserialize( $new_line['properties'] ); - $new_line['properties'] = array(); + $new_line['properties'] = []; foreach ( $props as $key => $val ) { if ( $key == 'image_id' ) { $new_line['properties'][ $key ] = intval( $val ); @@ -3371,7 +3371,7 @@ function eme_db_insert_group( $line ) { function eme_db_update_person( $person_id, $line ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . PEOPLE_TBNAME; - $where = array(); + $where = []; $where['person_id'] = intval( $person_id ); $person = eme_get_person( $person_id ); @@ -3384,7 +3384,7 @@ function eme_db_update_person( $person_id, $line ) { // some properties validation: only image_id as int is allowed $props = eme_unserialize( $new_line['properties'] ); - $new_line['properties'] = array(); + $new_line['properties'] = []; foreach ( $props as $key => $val ) { if ( $key == 'image_id' ) { $new_line['properties'][ $key ] = intval( $val ); @@ -3416,7 +3416,7 @@ function eme_db_update_person( $person_id, $line ) { function eme_db_update_group( $group_id, $line ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . GROUPS_TBNAME; - $where = array(); + $where = []; $where['group_id'] = intval( $group_id ); $group = eme_get_group( $group_id ); @@ -3435,7 +3435,7 @@ function eme_db_update_group( $group_id, $line ) { function eme_add_update_person_from_backend( $person_id = 0 ) { check_admin_referer( 'eme_admin', 'eme_admin_nonce' ); - $person = array(); + $person = []; if ( isset( $_POST['lastname'] ) ) { $person['lastname'] = eme_sanitize_request( $_POST['lastname'] ); } @@ -3507,7 +3507,7 @@ function eme_add_update_person_from_backend( $person_id = 0 ) { if ( isset( $_POST['groups'] ) ) { $groups = eme_sanitize_request( $_POST['groups'] ); } else { - $groups = array(); + $groups = []; } if ( isset( $_POST['properties'] ) ) { $person['properties'] = eme_sanitize_request( $_POST['properties'] ); @@ -3517,10 +3517,10 @@ function eme_add_update_person_from_backend( $person_id = 0 ) { if ( ! empty( $person['email'] ) && ! eme_is_email( $person['email'], 1 ) ) { $failure = '

    ' . esc_html__( 'Please enter a valid email address', 'events-made-easy' ) . '

    '; $person_id = 0; - $res = array( + $res = [ 0 => $failure, 1 => $person_id, - ); + ]; return $res; } $failure = ''; @@ -3557,10 +3557,10 @@ function eme_add_update_person_from_backend( $person_id = 0 ) { $res_id = $person_id; } } - $res = array( + $res = [ 0 => $failure, 1 => $res_id, - ); + ]; return $res; } @@ -3568,7 +3568,7 @@ function eme_add_update_group( $group_id = 0 ) { global $wpdb,$eme_db_prefix; check_admin_referer( 'eme_admin', 'eme_admin_nonce' ); $table = $eme_db_prefix . GROUPS_TBNAME; - $group = array(); + $group = []; if ( isset( $_POST['name'] ) ) { $group['name'] = eme_sanitize_request( $_POST['name'] ); } @@ -3576,8 +3576,8 @@ function eme_add_update_group( $group_id = 0 ) { $group['description'] = eme_sanitize_request( $_POST['description'] ); } $group['public'] = isset( $_POST['public'] ) ? intval( $_POST['public'] ) : 0; - $search_terms = array(); - $search_fields = array( 'search_membershipids', 'search_memberstatus', 'search_person', 'search_groups', 'search_memberid', 'search_customfields', 'search_customfieldids' ); + $search_terms = []; + $search_fields = [ 'search_membershipids', 'search_memberstatus', 'search_person', 'search_groups', 'search_memberid', 'search_customfields', 'search_customfieldids' ]; foreach ( $search_fields as $search_field ) { if ( isset( $_POST[ $search_field ] ) ) { $search_terms[ $search_field ] = esc_sql( eme_sanitize_request( $_POST[ $search_field ] ) ); @@ -3607,7 +3607,7 @@ function eme_add_update_group( $group_id = 0 ) { if ( isset( $_POST['persons'] ) ) { $persons = eme_sanitize_request( $_POST['persons'] ); } else { - $persons = array(); + $persons = []; } eme_update_grouppersons( $group_id, $persons ); } @@ -3618,7 +3618,7 @@ function eme_add_update_group( $group_id = 0 ) { if ( isset( $_POST['persons'] ) ) { $persons = eme_sanitize_request( $_POST['persons'] ); } else { - $persons = array(); + $persons = []; } eme_update_grouppersons( $group_id, $persons ); } @@ -3627,15 +3627,15 @@ function eme_add_update_group( $group_id = 0 ) { } function eme_add_familymember_from_frontend( $main_person_id, $familymember ) { - $person = array(); + $person = []; if ( ( ! isset( $_POST['eme_admin_nonce'] ) && ! isset( $_POST['eme_frontend_nonce'] ) ) || ( isset( $_POST['eme_admin_nonce'] ) && ! wp_verify_nonce( eme_sanitize_request($_POST['eme_admin_nonce']), 'eme_admin' ) ) || ( isset( $_POST['eme_frontend_nonce'] ) && ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) ) { - return array( + return [ 0 => 0, - 1 => esc_html__( 'Access denied!', 'events-made-easy' ) - ); + 1 => esc_html__( 'Access denied!', 'events-made-easy' ), + ]; } // lang detection @@ -3651,10 +3651,10 @@ function eme_add_familymember_from_frontend( $main_person_id, $familymember ) { $email = ''; } if ( ! empty( $email ) && ! eme_is_email( $email, 1 ) ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'Please enter a valid email address', 'events-made-easy' ), - ); + ]; } // most fields are taken from the main family person $country_code = ''; @@ -3662,10 +3662,10 @@ function eme_add_familymember_from_frontend( $main_person_id, $familymember ) { $country_code = eme_sanitize_request( $_POST['country_code'] ); $country_name = eme_get_country_name( $country_code ); if ( empty( $country_name ) ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'Invalid country code', 'events-made-easy' ), - ); + ]; } } $state_code = ''; @@ -3673,10 +3673,10 @@ function eme_add_familymember_from_frontend( $main_person_id, $familymember ) { $state_code = eme_sanitize_request( $_POST['state_code'] ); $state_name = eme_get_state_name( $state_code, $country_code, $lang ); if ( empty( $state_name ) ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'Invalid state code', 'events-made-easy' ), - ); + ]; } } @@ -3751,32 +3751,32 @@ function eme_add_familymember_from_frontend( $main_person_id, $familymember ) { } function eme_add_update_person_from_form( $person_id, $lastname = '', $firstname = '', $email = '', $wp_id = 0, $create_wp_user = 0, $return_fake_person = 0 ) { - $person = array(); + $person = []; if ( ( ! isset( $_POST['eme_admin_nonce'] ) && ! isset( $_POST['eme_frontend_nonce'] ) ) || ( isset( $_POST['eme_admin_nonce'] ) && ! wp_verify_nonce( eme_sanitize_request($_POST['eme_admin_nonce']), 'eme_admin' ) ) || ( isset( $_POST['eme_frontend_nonce'] ) && ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) ) { - return array( + return [ 0 => 0, - 1 => esc_html__( 'Access denied!', 'events-made-easy' ) - ); + 1 => esc_html__( 'Access denied!', 'events-made-easy' ), + ]; } if ( ! $return_fake_person && ! empty( $email ) && ! eme_is_email( $email, 1 ) ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'Please enter a valid email address', 'events-made-easy' ), - ); + ]; } // lang detection if ( $person_id ) { $person_being_updated = eme_get_person( $person_id ); if ( ! $person_being_updated ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'Error encountered while updating person', 'events-made-easy' ), - ); + ]; } // when a booking is done via the admin backend, take the existing language for that person if ( ! empty( $person_being_updated['lang'] ) && eme_is_admin_request() ) { @@ -3789,10 +3789,10 @@ function eme_add_update_person_from_form( $person_id, $lastname = '', $firstname } if ( $create_wp_user > 0 && ! eme_is_admin_request() && ! is_user_logged_in() && email_exists( $email ) ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'The email address belongs to an existing user. Please log in first before continuing to register with this email address.', 'events-made-easy' ), - ); + ]; } // check for correct country value @@ -3802,10 +3802,10 @@ function eme_add_update_person_from_form( $person_id, $lastname = '', $firstname $country_code = eme_sanitize_request( $_POST['country_code'] ); $country_name = eme_get_country_name( $country_code ); if ( empty( $country_name ) ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'Invalid country code', 'events-made-easy' ), - ); + ]; } } $state_code = ''; @@ -3813,10 +3813,10 @@ function eme_add_update_person_from_form( $person_id, $lastname = '', $firstname $state_code = eme_sanitize_request( $_POST['state_code'] ); $state_name = eme_get_state_name( $state_code, $country_code, $lang ); if ( empty( $state_name ) ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'Invalid state code', 'events-made-easy' ), - ); + ]; } } @@ -3899,15 +3899,15 @@ function eme_add_update_person_from_form( $person_id, $lastname = '', $firstname if ( ! empty( $_POST['subscribe_groups'] ) ) { eme_add_persongroups( $updated_personid, eme_sanitize_request( $_POST['subscribe_groups'] ) ); } - return array( + return [ 0 => $person_id, 1 => '', - ); + ]; } else { - return array( + return [ 0 => 0, 1 => esc_html__( 'Error encountered while updating person', 'events-made-easy' ), - ); + ]; } } else { $person['lastname'] = eme_sanitize_request( $lastname ); @@ -3922,15 +3922,15 @@ function eme_add_update_person_from_form( $person_id, $lastname = '', $firstname if ( ! empty( $_POST['subscribe_groups'] ) ) { eme_add_persongroups( $updated_personid, eme_sanitize_request( $_POST['subscribe_groups'] ) ); } - return array( + return [ 0 => $person_id, 1 => '', - ); + ]; } else { - return array( + return [ 0 => 0, 1 => esc_html__( 'Error encountered while adding person', 'events-made-easy' ), - ); + ]; } } } else { @@ -3950,18 +3950,18 @@ function eme_add_update_person_from_form( $person_id, $lastname = '', $firstname $person['email'] = $person_being_updated['email']; } if ( eme_is_empty_string( $person['email'] ) || ! eme_is_email( $person['email'], 1 ) ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'Please enter a valid email address', 'events-made-easy' ), - ); + ]; } // check for conflicts $existing_personid = eme_get_person_by_name_and_email( $person['lastname'], $person['firstname'], $person['email'] ); if ( $existing_personid && $existing_personid['person_id'] != $person_id ) { - return array( + return [ 0 => 0, 1 => esc_html__( 'Conflict with info from other person, please use another lastname, firstname or email', 'events-made-easy' ), - ); + ]; } // when updating a person using the person id, we won't change the wp_id (that should happen in the admin interface for the person) $person['wp_id'] = $person_being_updated['wp_id']; @@ -3971,15 +3971,15 @@ function eme_add_update_person_from_form( $person_id, $lastname = '', $firstname if ( ! empty( $_POST['subscribe_groups'] ) ) { eme_add_persongroups( $updated_personid, eme_sanitize_request( $_POST['subscribe_groups'] ) ); } - return array( + return [ 0 => $person_id, 1 => '', - ); + ]; } else { - return array( + return [ 0 => 0, 1 => esc_html__( 'Error encountered while updating person', 'events-made-easy' ), - ); + ]; } } } @@ -4078,7 +4078,7 @@ function eme_update_person_wp_id( $person_id, $wp_id ) { $wpdb->query( $sql ); // we'll set the wp_id and other info from wp too - $where = array(); + $where = []; $where['person_id'] = intval( $person_id ); $person_update = compact( 'lastname', 'firstname', 'email', 'wp_id' ); return $wpdb->update( $table, $person_update, $where ); @@ -4104,7 +4104,7 @@ function eme_update_people_gdpr( $person_ids, $gdpr = 1 ) { $ids_arr = explode( ',', $person_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("UPDATE $table SET gdpr=%d, gdpr_date=%s WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge(array($gdpr,$gdpr_date),$ids_arr)); + $sql = $wpdb->prepare("UPDATE $table SET gdpr=%d, gdpr_date=%s WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge([$gdpr,$gdpr_date], $ids_arr)); $wpdb->query( $sql ); } } @@ -4122,7 +4122,7 @@ function eme_update_people_massmail( $person_ids, $massmail = 1 ) { $ids_arr = explode( ',', $person_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "UPDATE $table SET massmail=%d WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge(array($massmail),$ids_arr)); + $sql = $wpdb->prepare( "UPDATE $table SET massmail=%d WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge([$massmail], $ids_arr)); $wpdb->query( $sql ); } } @@ -4133,7 +4133,7 @@ function eme_update_people_bdemail( $person_ids, $bd_email = 1 ) { $ids_arr = explode( ',', $person_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "UPDATE $table SET bd_mail=%d WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge(array($bd_mail),$ids_arr)); + $sql = $wpdb->prepare( "UPDATE $table SET bd_mail=%d WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge([$bd_mail], $ids_arr)); $wpdb->query( $sql ); } } @@ -4144,7 +4144,7 @@ function eme_update_people_language( $person_ids, $lang ) { $ids_arr = explode( ',', $person_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "UPDATE $table SET lang=%s WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge(array($lang),$ids_arr)); + $sql = $wpdb->prepare( "UPDATE $table SET lang=%s WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge([$lang], $ids_arr)); $wpdb->query( $sql ); } } @@ -4153,7 +4153,7 @@ function eme_get_indexed_users() { global $wpdb,$eme_db_prefix; $sql = "SELECT display_name, ID FROM $wpdb->users"; $users = $wpdb->get_results( $sql, ARRAY_A ); - $indexed_users = array(); + $indexed_users = []; foreach ( $users as $user ) { $indexed_users[ $user['ID'] ] = $user['display_name']; } @@ -4161,31 +4161,31 @@ function eme_get_indexed_users() { } function eme_get_wp_users( $search, $offset = 0, $pagesize = 0 ) { - $meta_query = array( + $meta_query = [ 'relation' => 'OR', - array( + [ 'key' => 'nickname', 'value' => $search, 'compare' => 'LIKE', - ), - array( + ], + [ 'key' => 'first_name', 'value' => $search, 'compare' => 'LIKE', - ), - array( + ], + [ 'key' => 'last_name', 'value' => $search, 'compare' => 'LIKE', - ), - ); - $args = array( + ], + ]; + $args = [ 'meta_query' => $meta_query, 'orderby' => 'ID', 'order' => 'ASC', 'count_total' => true, - 'fields' => array( 'ID' ), - ); + 'fields' => [ 'ID' ], + ]; if ( $pagesize > 0 ) { $args['offset'] = $offset; $args['number'] = $pagesize; @@ -4195,7 +4195,7 @@ function eme_get_wp_users( $search, $offset = 0, $pagesize = 0 ) { $user_query = new WP_User_Query( $args ); $users = $user_query->get_results(); // array of WP_User objects, like get_users $total = $user_query->get_total(); // int, total number of users (not just the first page) - return array( $users, $total ); + return [ $users, $total ]; } add_action( 'wp_ajax_eme_subscribe', 'eme_subscribe_ajax' ); @@ -4206,10 +4206,10 @@ function eme_subscribe_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $message = esc_html__( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4217,10 +4217,10 @@ function eme_subscribe_ajax() { if ( ! isset( $_POST['eme_frontend_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) { $message = esc_html__( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4229,10 +4229,10 @@ function eme_subscribe_ajax() { if ( ! eme_check_hcaptcha() ) { $message = esc_html__( 'Please check the hCaptcha box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4241,10 +4241,10 @@ function eme_subscribe_ajax() { if ( ! eme_check_recaptcha() ) { $message = esc_html__( 'Please check the Google reCAPTCHA box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4253,10 +4253,10 @@ function eme_subscribe_ajax() { if ( ! eme_check_captcha( 1 ) ) { $message = esc_html__( 'You entered an incorrect code', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4276,18 +4276,18 @@ function eme_subscribe_ajax() { eme_sub_send_mail( $eme_lastname, $eme_firstname, $eme_email, $eme_email_groups ); $message = esc_html__( 'A request for confirmation has been sent to the given email address.', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $message, - ) + ] ); } else { $message = esc_html__( 'Please enter a valid email address', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); } wp_die(); @@ -4296,7 +4296,7 @@ function eme_subscribe_ajax() { function eme_subform_shortcode( $atts ) { global $eme_plugin_url; eme_enqueue_frontend(); - $atts = shortcode_atts( array( 'template_id' => 0 ), $atts ); + $atts = shortcode_atts( [ 'template_id' => 0 ], $atts ); if ( !empty($atts['template_id']) ) { $format = eme_get_template_format( intval($atts['template_id']) ); } else { @@ -4325,10 +4325,10 @@ function eme_unsubscribe_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $message = esc_html__( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4337,10 +4337,10 @@ function eme_unsubscribe_ajax() { if ( ! isset( $_POST['eme_frontend_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) { $message = esc_html__( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4348,10 +4348,10 @@ function eme_unsubscribe_ajax() { if ( ! eme_check_hcaptcha() ) { $message = esc_html__( 'Please check the hCaptcha box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4360,10 +4360,10 @@ function eme_unsubscribe_ajax() { if ( ! eme_check_recaptcha() ) { $message = esc_html__( 'Please check the Google reCAPTCHA box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4372,10 +4372,10 @@ function eme_unsubscribe_ajax() { if ( ! eme_check_captcha( 1 ) ) { $message = esc_html__( 'You entered an incorrect code', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); wp_die(); } @@ -4393,18 +4393,18 @@ function eme_unsubscribe_ajax() { eme_unsub_send_mail( $eme_email, $eme_email_groups ); $message = esc_html__( 'A request for confirmation has been sent to the given email address.', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $message, - ) + ] ); } else { $message = esc_html__( 'Please enter a valid email address', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $message, - ) + ] ); } wp_die(); @@ -4413,7 +4413,7 @@ function eme_unsubscribe_ajax() { function eme_unsubform_shortcode( $atts ) { global $eme_plugin_url; eme_enqueue_frontend(); - $atts = shortcode_atts( array( 'template_id' => 0 ), $atts ); + $atts = shortcode_atts( [ 'template_id' => 0 ], $atts ); if ( !empty($atts['template_id']) ) { $format = eme_get_template_format( intval($atts['template_id']) ); } else { @@ -4558,7 +4558,7 @@ function eme_delete_person_groups( $person_ids ) { $ids_arr = explode( ',', $person_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "DELETE FROM $usergroups_table WHERE person_id IN ($commaDelimitedPlaceholders)",$ids_arr); + $sql = $wpdb->prepare( "DELETE FROM $usergroups_table WHERE person_id IN ($commaDelimitedPlaceholders)", $ids_arr); $wpdb->query( $sql ); } } @@ -4569,7 +4569,7 @@ function eme_delete_person_answers( $person_ids ) { $ids_arr = explode( ',', $person_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "DELETE FROM $answers_table WHERE related_id IN ($commaDelimitedPlaceholders) AND type='person'",$ids_arr); + $sql = $wpdb->prepare( "DELETE FROM $answers_table WHERE related_id IN ($commaDelimitedPlaceholders) AND type='person'", $ids_arr); $wpdb->query( $sql ); } } @@ -4581,9 +4581,9 @@ function eme_delete_person_memberships( $person_ids ) { $ids_arr = explode( ',', $person_ids ); if ( eme_array_integers( $ids_arr ) ) { $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "DELETE FROM $answers_table WHERE type='member' AND related_id IN (SELECT member_id FROM $members_table WHERE person_id IN ($commaDelimitedPlaceholders))",$ids_arr); + $sql = $wpdb->prepare( "DELETE FROM $answers_table WHERE type='member' AND related_id IN (SELECT member_id FROM $members_table WHERE person_id IN ($commaDelimitedPlaceholders))", $ids_arr); $wpdb->query( $sql ); - $sql = $wpdb->prepare( "DELETE FROM $members_table WHERE person_id IN ($commaDelimitedPlaceholders)",$ids_arr); + $sql = $wpdb->prepare( "DELETE FROM $members_table WHERE person_id IN ($commaDelimitedPlaceholders)", $ids_arr); $wpdb->query( $sql ); } } @@ -4592,14 +4592,14 @@ function eme_people_answers( $person_id, $new_person = 0 ) { return eme_store_people_answers( $person_id, $new_person ); } function eme_store_people_answers( $person_id, $new_person = 0, $backend = 0 ) { - $all_answers = array(); + $all_answers = []; if ( $person_id > 0 ) { $all_answers = eme_get_person_answers( $person_id ); wp_cache_delete( "eme_person_answers $person_id" ); } - $answer_ids_seen = array(); - $formfield_ids_seen = array(); + $answer_ids_seen = []; + $formfield_ids_seen = []; // for a new person the POST fields have key 0, since the person_id wasn't known yet if ( $new_person ) { $field_person_id = 0; @@ -4608,31 +4608,31 @@ function eme_store_people_answers( $person_id, $new_person = 0, $backend = 0 ) { } if ( isset( $_POST['dynamic_personfields'][ $field_person_id ] ) ) { foreach ( $_POST['dynamic_personfields'][ $field_person_id ] as $key => $value ) { - if ( preg_match( '/^FIELD(\d+)$/', $key, $matches ) ) { - $field_id = intval( $matches[1] ); - $formfield = eme_get_formfield( $field_id ); + if ( preg_match( '/^FIELD(\d+)$/', eme_sanitize_request($key), $matches ) ) { + $field_id = intval( $matches[1] ); + $formfield = eme_get_formfield( $field_id ); if ( ! empty( $formfield ) && $formfield['field_purpose'] == 'people' ) { $formfield_ids_seen[] = $field_id; - // for multivalue fields like checkbox, the value is in fact an array - // to store it, we make it a simple "multi" string using eme_convert_array2multi, so later on when we need to parse the values - // (when editing a booking), we can re-convert it to an array with eme_convert_multi2array (see eme_formfields.php) + // for multivalue fields like checkbox, the value is in fact an array + // to store it, we make it a simple "multi" string using eme_convert_array2multi, so later on when we need to parse the values + // (when editing a booking), we can re-convert it to an array with eme_convert_multi2array (see eme_formfields.php) if ( is_array( $value ) ) { $value = eme_convert_array2multi( $value ); } if ( $formfield['field_type'] == 'textarea' ) { - $value = eme_sanitize_textarea( $value ); + $value = eme_sanitize_textarea( $value ); } elseif ( $formfield['field_type'] == 'time_js' ) { $value = eme_convert_localized_time( $formfield['field_attributes'], eme_sanitize_request( $value ) ); } else { $value = eme_sanitize_request( $value ); } - $answer_id = eme_get_answerid( $all_answers, $person_id, 'person', $field_id ); + $answer_id = eme_get_answerid( $all_answers, $person_id, 'person', $field_id ); if ( $answer_id ) { eme_update_answer( $answer_id, $value ); } else { $answer_id = eme_insert_answer( 'person', $person_id, $field_id, $value ); } - $answer_ids_seen[] = $answer_id; + $answer_ids_seen[] = $answer_id; } } } @@ -4650,11 +4650,11 @@ function eme_store_people_answers( $person_id, $new_person = 0, $backend = 0 ) { } function eme_store_family_answers( $person_id, $familymember ) { - $all_answers = array(); + $all_answers = []; $all_answers = eme_get_person_answers( $person_id ); - $answer_ids_seen = array(); - $formfield_ids_seen = array(); + $answer_ids_seen = []; + $formfield_ids_seen = []; foreach ( $familymember as $key => $value ) { if ( preg_match( '/^FIELD(\d+)$/', $key, $matches ) ) { $field_id = intval( $matches[1] ); @@ -4703,7 +4703,7 @@ function eme_people_autocomplete_ajax( $no_wp_die = 0, $wp_membership_required = ( isset( $_POST['eme_frontend_nonce'] ) && ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) ) { wp_die(); } - $return = array(); + $return = []; $q = ''; if ( isset( $_REQUEST['lastname'] ) ) { $q = strtolower( eme_sanitize_request( $_REQUEST['lastname'] ) ); @@ -4748,7 +4748,7 @@ function eme_people_autocomplete_ajax( $no_wp_die = 0, $wp_membership_required = } $persons = eme_get_persons( '', $search ); foreach ( $persons as $item ) { - $record = array(); + $record = []; $record['lastname'] = eme_esc_html( $item['lastname'] ); $record['firstname'] = eme_esc_html( $item['firstname'] ); $record['address1'] = eme_esc_html( $item['address1'] ); @@ -4767,9 +4767,9 @@ function eme_people_autocomplete_ajax( $no_wp_die = 0, $wp_membership_required = } } if ( $search_tables == 'wp_users' || $search_tables == 'both' ) { - list($persons,$total) = eme_get_wp_users( $q ); + [$persons, $total] = eme_get_wp_users( $q ); foreach ( $persons as $item ) { - $record = array(); + $record = []; $user_info = get_userdata( $item->ID ); $phone = eme_esc_html( eme_get_user_phone( $item->ID ) ); $record['lastname'] = eme_esc_html( $user_info->user_lastname ); @@ -4821,9 +4821,9 @@ function eme_ajax_people_list( $dynamic_groupname = '' ) { $table = $eme_db_prefix . GROUPS_TBNAME; $group['type'] = 'dynamic_people'; $group['name'] = $dynamic_groupname . ' ' . esc_html__( '(Dynamic)', 'events-made-easy' ); - $search_terms = array(); + $search_terms = []; // the same as in add_update_group - $search_fields = array( 'search_membershipids', 'search_memberstatus', 'search_person', 'search_groups', 'search_memberid', 'search_customfields', 'search_customfieldids' ); + $search_fields = [ 'search_membershipids', 'search_memberstatus', 'search_person', 'search_groups', 'search_memberid', 'search_customfields', 'search_customfieldids' ]; foreach ( $search_fields as $search_field ) { if ( isset( $_POST[ $search_field ] ) ) { $search_terms[ $search_field ] = esc_sql( eme_sanitize_request( $_POST[ $search_field ] ) ); @@ -4835,7 +4835,7 @@ function eme_ajax_people_list( $dynamic_groupname = '' ) { $formfields = eme_get_formfields( '', 'people' ); - $jTableResult = array(); + $jTableResult = []; $start = ( isset( $_REQUEST['jtStartIndex'] ) ) ? intval( $_REQUEST['jtStartIndex'] ) : 0; $pagesize = ( isset( $_REQUEST['jtPageSize'] ) ) ? intval( $_REQUEST['jtPageSize'] ) : 10; $sorting = ( ! empty( $_REQUEST['jtSorting'] ) && ! empty( eme_sanitize_sql_orderby( $_REQUEST['jtSorting'] ) ) ) ? 'ORDER BY ' . esc_sql(eme_sanitize_sql_orderby( $_REQUEST['jtSorting']) ) : ''; @@ -4844,9 +4844,9 @@ function eme_ajax_people_list( $dynamic_groupname = '' ) { $recordCount = $wpdb->get_var( $count_sql ); $rows = $wpdb->get_results( $sql, ARRAY_A ); $wp_users = eme_get_indexed_users(); - $records = array(); + $records = []; foreach ( $rows as $item ) { - $record = array(); + $record = []; if ( empty( $item['lastname'] ) ) { $item['lastname'] = esc_html__( 'No surname', 'events-made-easy' ); } @@ -4946,13 +4946,13 @@ function eme_ajax_groups_list() { print wp_json_encode( $ajaxResult ); wp_die(); } - $jTableResult = array(); + $jTableResult = []; $sql = "SELECT COUNT(*) FROM $table"; $recordCount = $wpdb->get_var( $sql ); $sql = "SELECT group_id,COUNT(*) AS groupcount FROM $usergroups_table GROUP BY group_id"; $res = $wpdb->get_results( $sql, ARRAY_A ); - $groupcount = array(); + $groupcount = []; foreach ( $res as $val ) { $groupcount[ $val['group_id'] ] = $val['groupcount']; } @@ -4962,9 +4962,9 @@ function eme_ajax_groups_list() { $sorting = ( ! empty( $_REQUEST['jtSorting'] ) && ! empty( eme_sanitize_sql_orderby( $_REQUEST['jtSorting'] ) ) ) ? 'ORDER BY ' . esc_sql( $_REQUEST['jtSorting'] ) : ''; $sql = "SELECT * FROM $table $sorting LIMIT $start,$pagesize"; $groups = $wpdb->get_results( $sql, ARRAY_A ); - $records = array(); + $records = []; foreach ( $groups as $group ) { - $record = array(); + $record = []; if ( empty( $group['name'] ) ) { $group['name'] = esc_html__( 'No name', 'events-made-easy' ); } @@ -5021,7 +5021,7 @@ function eme_ajax_people_select2() { $table = $eme_db_prefix . PEOPLE_TBNAME; - $jTableResult = array(); + $jTableResult = []; $q = isset( $_REQUEST['q'] ) ? strtolower( eme_sanitize_request( $_REQUEST['q'] ) ) : ''; if ( ! empty( $q ) ) { $where = "(lastname LIKE '%" . esc_sql( $wpdb->esc_like($q) ) . "%' OR firstname LIKE '%" . esc_sql( $wpdb->esc_like($q) ) . "%')"; @@ -5034,10 +5034,10 @@ function eme_ajax_people_select2() { $recordCount = $wpdb->get_var( $count_sql ); $limit = "LIMIT $start,$pagesize"; - $records = array(); + $records = []; $persons = eme_get_persons( '', $where, $limit ); foreach ( $persons as $person ) { - $record = array(); + $record = []; $record['id'] = $person['person_id']; // no eme_esc_html here, select2 does it own escaping upon arrival $record['text'] = eme_format_full_name( $person['firstname'], $person['lastname'] ) . ' (' . $person['email'] . ')'; @@ -5069,7 +5069,7 @@ function eme_ajax_store_people_query() { function eme_ajax_manage_people() { check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); - $ajaxResult = array(); + $ajaxResult = []; if ( isset( $_POST['do_action'] ) ) { $do_action = eme_sanitize_request( $_POST['do_action'] ); $ids = eme_sanitize_request( $_POST['person_id'] ); @@ -5156,7 +5156,7 @@ function eme_ajax_manage_groups() { $ids = eme_sanitize_request( $_POST['group_id'] ); $ids_arr = explode( ',', $ids ); if ( ! eme_array_integers( $ids_arr ) || ! current_user_can( get_option( 'eme_cap_edit_people' ) ) ) { - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'Error'; $ajaxResult['Message'] = esc_html__( 'Access denied!', 'events-made-easy' ); print wp_json_encode( $ajaxResult ); @@ -5172,7 +5172,7 @@ function eme_ajax_manage_groups() { } function eme_ajax_action_untrash_people( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; eme_untrash_people( $ids ); $ajaxResult['Result'] = 'OK'; $ajaxResult['htmlmessage'] = esc_html__( 'People recovered from trash bin.', 'events-made-easy' ); @@ -5180,7 +5180,7 @@ function eme_ajax_action_untrash_people( $ids ) { } function eme_ajax_action_trash_people( $ids, $transferto_id=0 ) { - $ajaxResult = array(); + $ajaxResult = []; if ( ! empty( $transferto_id ) ) { eme_transfer_person_bookings( $ids, $transferto_id ); eme_transfer_person_task_signups( $ids, $transferto_id ); @@ -5192,7 +5192,7 @@ function eme_ajax_action_trash_people( $ids, $transferto_id=0 ) { } function eme_ajax_action_gdpr_trash_people( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; eme_gdpr_trash_people( $ids ); $ajaxResult['Result'] = 'OK'; $ajaxResult['htmlmessage'] = esc_html__( 'Personal data removed and moved to trash bin.', 'events-made-easy' ); @@ -5200,7 +5200,7 @@ function eme_ajax_action_gdpr_trash_people( $ids ) { } function eme_ajax_action_gdpr_approve_people( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; eme_update_people_gdpr( $ids ); $ajaxResult['Result'] = 'OK'; $ajaxResult['htmlmessage'] = esc_html__( 'GDPR approval set to "Yes" (make sure the selected persons are aware of this).', 'events-made-easy' ); @@ -5208,7 +5208,7 @@ function eme_ajax_action_gdpr_approve_people( $ids ) { } function eme_ajax_action_gdpr_unapprove_people( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; eme_update_people_gdpr( $ids, 0 ); $ajaxResult['Result'] = 'OK'; $ajaxResult['htmlmessage'] = esc_html__( 'GDPR approval set to "No" (make sure the selected persons are aware of this).', 'events-made-easy' ); @@ -5216,7 +5216,7 @@ function eme_ajax_action_gdpr_unapprove_people( $ids ) { } function eme_ajax_action_set_massmail_people( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; eme_update_people_massmail( $ids ); $ajaxResult['Result'] = 'OK'; $ajaxResult['htmlmessage'] = esc_html__( 'Massmail set to "Yes" (make sure the selected persons are aware of this).', 'events-made-easy' ); @@ -5224,7 +5224,7 @@ function eme_ajax_action_set_massmail_people( $ids ) { } function eme_ajax_action_set_nomassmail_people( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; eme_update_people_massmail( $ids, 0 ); $ajaxResult['Result'] = 'OK'; $ajaxResult['htmlmessage'] = esc_html__( 'Massmail set to "No" (make sure the selected persons are aware of this).', 'events-made-easy' ); @@ -5232,7 +5232,7 @@ function eme_ajax_action_set_nomassmail_people( $ids ) { } function eme_ajax_action_set_bdemail_people( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; eme_update_people_bdemail( $ids ); $ajaxResult['Result'] = 'OK'; $ajaxResult['htmlmessage'] = esc_html__( 'Birthday email set to "Yes".', 'events-made-easy' ); @@ -5240,7 +5240,7 @@ function eme_ajax_action_set_bdemail_people( $ids ) { } function eme_ajax_action_set_nobdemail_people( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; eme_update_people_bdemail( $ids, 0 ); $ajaxResult['Result'] = 'OK'; $ajaxResult['htmlmessage'] = esc_html__( 'Birthday email set to "No".', 'events-made-easy' ); @@ -5248,7 +5248,7 @@ function eme_ajax_action_set_nobdemail_people( $ids ) { } function eme_ajax_action_set_people_language( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; $lang = eme_sanitize_request( $_POST['language'] ); eme_update_people_language( $ids, $lang ); $ajaxResult['Result'] = 'OK'; @@ -5257,7 +5257,7 @@ function eme_ajax_action_set_people_language( $ids ) { } function eme_ajax_action_delete_people( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; if ( ! empty( $_POST['transferto_id'] ) ) { $to_person_id = intval( $_POST['transferto_id'] ); eme_transfer_person_bookings( $ids, $to_person_id ); @@ -5270,7 +5270,7 @@ function eme_ajax_action_delete_people( $ids ) { } function eme_ajax_action_add_people_to_group( $ids_arr, $group_id ) { - $ajaxResult = array(); + $ajaxResult = []; foreach ( $ids_arr as $person_id ) { eme_add_persongroups( $person_id, $group_id ); } @@ -5281,7 +5281,7 @@ function eme_ajax_action_add_people_to_group( $ids_arr, $group_id ) { } function eme_ajax_action_delete_people_from_group( $ids_arr, $group_id ) { - $ajaxResult = array(); + $ajaxResult = []; foreach ( $ids_arr as $person_id ) { eme_delete_personfromgroup( $person_id, $group_id ); } @@ -5292,7 +5292,7 @@ function eme_ajax_action_delete_people_from_group( $ids_arr, $group_id ) { } function eme_ajax_action_delete_groups( $ids ) { - $ajaxResult = array(); + $ajaxResult = []; eme_delete_groups( $ids ); $ajaxResult['Result'] = 'OK'; $ajaxResult['htmlmessage'] = esc_html__( 'Groups deleted.', 'events-made-easy' ); @@ -5318,7 +5318,7 @@ function eme_ajax_generate_people_pdf( $ids_arr, $template_id, $template_id_head $orientation = $template['properties']['pdf_orientation']; $pagesize = $template['properties']['pdf_size']; if ( $pagesize == 'custom' ) { - $pagesize = array( 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ); + $pagesize = [ 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ]; } $dompdf->setPaper( $pagesize, $orientation ); diff --git a/eme-recurrence.php b/eme-recurrence.php index 3919e3e6..6b3e0da5 100644 --- a/eme-recurrence.php +++ b/eme-recurrence.php @@ -5,7 +5,7 @@ } function eme_new_recurrence() { - $recurrence = array( + $recurrence = [ 'recurrence_start_date' => '', 'recurrence_end_date' => '', 'recurrence_interval' => 1, @@ -15,7 +15,7 @@ function eme_new_recurrence() { 'recurrence_specific_days' => '', 'event_duration' => 1, 'holidays_id' => 0, - ); + ]; return $recurrence; } @@ -31,7 +31,7 @@ function eme_get_recurrence( $recurrence_id ) { function eme_get_recurrence_days( $recurrence ) { global $eme_timezone; - $matching_days = array(); + $matching_days = []; if ( $recurrence['recurrence_freq'] == 'specific' ) { $specific_days = explode( ',', $recurrence['recurrence_specific_days'] ); @@ -45,12 +45,12 @@ function eme_get_recurrence_days( $recurrence ) { $start_date_obj = new ExpressiveDate( $recurrence['recurrence_start_date'], $eme_timezone ); $end_date_obj = new ExpressiveDate( $recurrence['recurrence_end_date'], $eme_timezone ); - $holidays = array(); + $holidays = []; if ( isset( $recurrence['holidays_id'] ) && $recurrence['holidays_id'] > 0 ) { $holidays = eme_get_holiday_listinfo( $recurrence['holidays_id'] ); } - $last_week_start = array( 25, 22, 25, 24, 25, 24, 25, 25, 24, 25, 24, 25 ); + $last_week_start = [ 25, 22, 25, 24, 25, 24, 25, 25, 24, 25, 24, 25 ]; $weekdays = explode( ',', $recurrence['recurrence_byday'] ); $counter = 0; @@ -242,7 +242,7 @@ function eme_db_update_recurrence( $recurrence, $event, $only_change_recdates = $recurrence['recurrence_end_date'] = $last_day; } - $where = array( 'recurrence_id' => $recurrence['recurrence_id'] ); + $where = [ 'recurrence_id' => $recurrence['recurrence_id'] ]; $wpdb->show_errors( true ); $wpdb->update( $recurrence_table, $recurrence, $where ); $wpdb->show_errors( false ); @@ -375,15 +375,15 @@ function eme_get_recurrence_desc( $recurrence_id ) { return; } - $weekdays_name = array( __( 'Monday' ), __( 'Tuesday' ), __( 'Wednesday' ), __( 'Thursday' ), __( 'Friday' ), __( 'Saturday' ), __( 'Sunday' ) ); - $monthweek_name = array( + $weekdays_name = [ __( 'Monday' ), __( 'Tuesday' ), __( 'Wednesday' ), __( 'Thursday' ), __( 'Friday' ), __( 'Saturday' ), __( 'Sunday' ) ]; + $monthweek_name = [ '1' => __( 'the first %s of the month', 'events-made-easy' ), '2' => __( 'the second %s of the month', 'events-made-easy' ), '3' => __( 'the third %s of the month', 'events-made-easy' ), '4' => __( 'the fourth %s of the month', 'events-made-easy' ), '5' => __( 'the fifth %s of the month', 'events-made-easy' ), '-1' => __( 'the last %s of the month', 'events-made-easy' ), - ); + ]; $output = sprintf( __( 'From %1$s to %2$s', 'events-made-easy' ), eme_localized_date( $recurrence['recurrence_start_date'], $eme_timezone ), eme_localized_date( $recurrence['recurrence_end_date'], $eme_timezone ) ) . ', '; if ( $recurrence['recurrence_freq'] == 'daily' ) { $freq_desc = __( 'everyday', 'events-made-easy' ); @@ -401,7 +401,7 @@ function eme_get_recurrence_desc( $recurrence_id ) { } } $weekday_array = explode( ',', $recurrence['recurrence_byday'] ); - $natural_days = array(); + $natural_days = []; foreach ( $weekday_array as $day ) { array_push( $natural_days, $weekdays_name[ $day - 1 ] ); } @@ -418,7 +418,7 @@ function eme_get_recurrence_desc( $recurrence_id ) { $recurrence['recurrence_byday'] = eme_localized_date( $recurrence['recurrence_start_date'], $eme_timezone, 'e' ); } $weekday_array = explode( ',', $recurrence['recurrence_byday'] ); - $natural_days = array(); + $natural_days = []; foreach ( $weekday_array as $day ) { array_push( $natural_days, $weekdays_name[ $day - 1 ] ); } @@ -431,7 +431,7 @@ function eme_get_recurrence_desc( $recurrence_id ) { } } elseif ( $recurrence['recurrence_freq'] == 'specific' ) { $specific_days = eme_get_recurrence_days( $recurrence ); - $natural_days = array(); + $natural_days = []; $eme_date_obj_now = new ExpressiveDate( 'now', $eme_timezone ); foreach ( $specific_days as $day ) { $date_obj = new ExpressiveDate( $day, $eme_timezone ); @@ -470,7 +470,7 @@ function eme_ajax_recurrences_list() { check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); if ( ! current_user_can( get_option( 'eme_cap_list_events' ) ) ) { - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'Error'; $ajaxResult['Message'] = __( 'Access denied!', 'events-made-easy' ); print wp_json_encode( $ajaxResult ); @@ -489,7 +489,7 @@ function eme_ajax_recurrences_list() { $search_end_date = isset( $_REQUEST['search_end_date'] ) && eme_is_date( $_REQUEST['search_end_date'] ) ? esc_sql( eme_sanitize_request($_REQUEST['search_end_date'])) : ''; $where = ''; - $where_arr = array(); + $where_arr = []; if ( ! empty( $search_name ) ) { $where_arr[] = "event_name like '%" . $search_name . "%'"; } @@ -524,7 +524,7 @@ function eme_ajax_recurrences_list() { } $recurrences = $wpdb->get_results( $sql, ARRAY_A ); - $rows = array(); + $rows = []; foreach ( $recurrences as $recurrence ) { // due to our select with natural join, $recurrence contains everything for an event too (except eme_unserialized properties // for ease of code, we'll set $event=$recurrence and use $event where logical @@ -556,7 +556,7 @@ function eme_ajax_recurrences_list() { $duration_string = sprintf( '%d %s, %s-%s', $duration_days, $day_string, eme_localized_time( $event['event_start'], $eme_timezone ), eme_localized_time( $event['event_end'], $eme_timezone ) ); } - $record = array(); + $record = []; $record['recurrence_id'] = $recurrence['recurrence_id']; $record['event_name'] = "" . eme_trans_esc_html( $event['event_name'] ) . ''; $record['copy'] = ""; @@ -580,7 +580,7 @@ function eme_ajax_recurrences_list() { if ( ! empty( $event['event_category_ids'] ) ) { $categories = explode( ',', $event['event_category_ids'] ); $record['event_name'] .= "
    "; - $cat_names = array(); + $cat_names = []; foreach ( $categories as $cat ) { $category = eme_get_category( $cat ); if ( $category ) { @@ -621,7 +621,7 @@ function eme_ajax_recurrences_list() { $rows[] = $record; } - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'OK'; $ajaxResult['TotalRecordCount'] = $recurrences_count; $ajaxResult['Records'] = $rows; @@ -631,7 +631,7 @@ function eme_ajax_recurrences_list() { function eme_ajax_manage_recurrences() { check_ajax_referer( 'eme_admin', 'eme_admin_nonce' ); - $ajaxResult = array(); + $ajaxResult = []; if ( isset( $_REQUEST['do_action'] ) ) { $do_action = eme_sanitize_request( $_REQUEST['do_action'] ); $rec_new_start_date = eme_sanitize_request( $_REQUEST['rec_new_start_date'] ); @@ -674,7 +674,7 @@ function eme_ajax_action_recurrences_delete( $ids_arr ) { foreach ( $ids_arr as $recurrence_id ) { eme_db_delete_recurrence( $recurrence_id ); } - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'OK'; $ajaxResult['Message'] = __( 'Recurrences deleted and events moved to trash', 'events-made-easy' ); print wp_json_encode( $ajaxResult ); @@ -685,7 +685,7 @@ function eme_ajax_action_recurrences_status( $ids_arr, $status ) { $events_ids = eme_get_recurrence_eventids( $recurrence_id ); eme_change_event_status( $events_ids, $status ); } - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'OK'; $ajaxResult['Message'] = __( 'Recurrences status updated', 'events-made-easy' ); print wp_json_encode( $ajaxResult ); @@ -715,7 +715,7 @@ function eme_ajax_action_recurrences_extend( $ids_arr, $rec_new_start_date, $rec unset( $event ); } } - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['Result'] = 'OK'; $ajaxResult['Message'] = __( 'Start and end date adjusted for the selected recurrences', 'events-made-easy' ); print wp_json_encode( $ajaxResult ); diff --git a/eme-rsvp.php b/eme-rsvp.php index a6825c80..e98ee5a9 100644 --- a/eme-rsvp.php +++ b/eme-rsvp.php @@ -5,7 +5,7 @@ } function eme_new_booking() { - $booking = array( + $booking = [ 'event_id' => 0, 'person_id' => 0, 'payment_id' => 0, @@ -21,18 +21,18 @@ function eme_new_booking() { 'pg_pid' => '', 'discount' => '', 'discountids' => '', - 'dcodes_entered' => array(), - 'dcodes_used' => array(), + 'dcodes_entered' => [], + 'dcodes_used' => [], 'dgroupid' => 0, 'waitinglist' => 0, - ); + ]; return $booking; } function eme_add_booking_form( $event_id, $only_if_not_registered = 0 ) { $event = eme_get_event( $event_id ); - $event_ids = array( 0 => $event ); + $event_ids = [ 0 => $event ]; $is_multibooking = 0; // we don't worry about the eme_register_empty_seats param, for attendance-like events it is checked later on return eme_add_multibooking_form( $event_ids, 0, 0, 0, 0, 0, $is_multibooking, $only_if_not_registered ); @@ -207,14 +207,14 @@ function eme_add_multibooking_form( $events, $template_id_header = 0, $template_ if ( $is_multibooking && $only_one_event ) { if ( $simple ) { $value = eme_replace_event_placeholders( $event_booking_format_entry, $tmp_event ); - $list = array( $event_id => $value ); - $form_html .= " '; + $list = [ $event_id => $value ]; + $form_html .= " '; } else { $form_html .= "'; } } elseif ( $is_multibooking && $simple ) { $value = eme_replace_event_placeholders( $event_booking_format_entry, $tmp_event ); - $list = array( $event_id => $value ); + $list = [ $event_id => $value ]; $form_html .= eme_ui_checkbox( 0, 'eme_event_ids', $list ); } else { $form_html .= ""; @@ -239,7 +239,7 @@ function eme_add_multibooking_form( $events, $template_id_header = 0, $template_ $event_id = $tmp_event['event_id']; $var_prefix = "bookings[$event_id]["; $var_postfix = ']'; - $fieldname = "${var_prefix}bookedSeats${var_postfix}"; + $fieldname = "{$var_prefix}bookedSeats{$var_postfix}"; $form_html .= ""; } } @@ -255,7 +255,7 @@ function eme_add_multibooking_form( $events, $template_id_header = 0, $template_ function eme_add_booking_form_shortcode( $atts ) { eme_enqueue_frontend(); - extract( shortcode_atts( array( 'id' => 0 ), $atts ) ); + extract( shortcode_atts( [ 'id' => 0 ], $atts ) ); if ( $id ) { return eme_add_booking_form( $id ); } @@ -264,8 +264,8 @@ function eme_add_booking_form_shortcode( $atts ) { function eme_add_simple_multibooking_form_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => 0, 'recurrence_id' => 0, 'category_id' => 0, @@ -278,8 +278,8 @@ function eme_add_simple_multibooking_form_shortcode( $atts ) { 'only_one_seat' => 0, 'scope' => '', 'order' => 'ASC', - ), - $atts + ], + $atts ) ); $register_empty_seats = filter_var( $register_empty_seats, FILTER_VALIDATE_BOOLEAN ); @@ -305,8 +305,8 @@ function eme_add_simple_multibooking_form_shortcode( $atts ) { function eme_add_multibooking_form_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => '', 'recurrence_id' => 0, 'category_id' => 0, @@ -321,8 +321,8 @@ function eme_add_multibooking_form_shortcode( $atts ) { 'scope' => '', 'order' => 'ASC', 'simple' => 0, - ), - $atts + ], + $atts ) ); $register_empty_seats = filter_var( $register_empty_seats, FILTER_VALIDATE_BOOLEAN ); @@ -349,8 +349,8 @@ function eme_add_multibooking_form_shortcode( $atts ) { function eme_booking_list_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => 0, 'template_id' => 0, 'template_id_header' => 0, @@ -358,8 +358,8 @@ function eme_booking_list_shortcode( $atts ) { 'rsvp_status' => 0, 'approval_status' => 0, 'paid_status' => 0, - ), - $atts + ], + $atts ) ); $approval_status = intval( $approval_status ); @@ -385,8 +385,8 @@ function eme_booking_list_shortcode( $atts ) { function eme_mybooking_list_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => 0, 'template_id' => 0, 'template_id_header' => 0, @@ -396,8 +396,8 @@ function eme_mybooking_list_shortcode( $atts ) { 'rsvp_status' => 0, 'approval_status' => 0, 'paid_status' => 0, - ), - $atts + ], + $atts ) ); $approval_status = intval( $approval_status ); @@ -433,8 +433,8 @@ function eme_mybooking_list_shortcode( $atts ) { function eme_attendee_list_shortcode( $atts ) { eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'id' => 0, 'template_id' => 0, 'template_id_header' => 0, @@ -443,8 +443,8 @@ function eme_attendee_list_shortcode( $atts ) { 'approval_status' => 0, 'paid_status' => 0, 'order' => '', - ), - $atts + ], + $atts ) ); $approval_status = intval( $approval_status ); @@ -471,8 +471,8 @@ function eme_attendees_report_link_shortcode( $atts ) { global $post; eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'title' => __( 'Attendees CSV', 'events-made-easy' ), 'scope' => 'this_month', 'event_template_id' => 0, @@ -480,8 +480,8 @@ function eme_attendees_report_link_shortcode( $atts ) { 'category' => '', 'notcategory' => '', 'public_access' => 0, - ), - $atts + ], + $atts ) ); $public_access = filter_var( $public_access, FILTER_VALIDATE_BOOLEAN ); @@ -507,15 +507,15 @@ function eme_bookings_report_link_shortcode( $atts ) { global $post; eme_enqueue_frontend(); extract( - shortcode_atts( - array( + shortcode_atts( + [ 'title' => __( 'Bookings CSV', 'events-made-easy' ), 'event_id' => 0, 'template_id' => 0, 'template_id_header' => 0, 'public_access' => 0, - ), - $atts + ], + $atts ) ); $public_access = filter_var( $public_access, FILTER_VALIDATE_BOOLEAN ); @@ -571,7 +571,7 @@ function eme_bookings_frontend_csv_report( $event_id, $template_id, $template_id $event = eme_get_event( $event_id ); if ( ! empty( $event ) ) { foreach ( $bookings as $booking ) { - $line = array(); + $line = []; $format_arr = explode( ',', $format ); $line_count = 1; foreach ( $format_arr as $single_format ) { @@ -587,7 +587,7 @@ function eme_bookings_frontend_csv_report( $event_id, $template_id, $template_id // now we have a line that contains arrays on every position, with $line_count indicating the max size of an arr in the line // so let's use that to output multiple lines for ( $i = 0;$i < $line_count;$i++ ) { - $output = array(); + $output = []; foreach ( $line as $el_arr ) { if ( isset( $el_arr[ $i ] ) ) { $output[] = $el_arr[ $i ]; @@ -619,11 +619,11 @@ function eme_attendees_frontend_csv_report( $scope, $category, $notcategory, $ev header( 'Content-type: text/csv' ); header( 'Content-Disposition: attachment; filename=report-' . date( 'Ymd-His' ) . '.csv' ); $fp = fopen( 'php://output', 'w' ); - $headers = array( __( 'Title\Date', 'events-made-easy' ) ); + $headers = [ __( 'Title\Date', 'events-made-easy' ) ]; - $all_attendees = array(); - $all_attendees_rec = array(); - $all_dates = array(); + $all_attendees = []; + $all_attendees_rec = []; + $all_dates = []; foreach ( $events as $event ) { $event_id = $event['event_id']; $recurrence_id = $event['recurrence_id']; @@ -640,9 +640,9 @@ function eme_attendees_frontend_csv_report( $scope, $category, $notcategory, $ev $headers[] = $event_start_date; } eme_fputcsv( $fp, $headers ); - $handled_recurrence_ids = array(); + $handled_recurrence_ids = []; foreach ( $events as $event ) { - $line = array(); + $line = []; $event_id = $event['event_id']; $recurrence_id = $event['recurrence_id']; if ( isset( $handled_recurrence_ids[ $recurrence_id ] ) ) { @@ -723,7 +723,7 @@ function eme_cancel_bookings_form( $event_id ) { } function eme_cancel_bookings_form_shortcode( $atts ) { - extract( shortcode_atts( array( 'id' => 0 ), $atts ) ); + extract( shortcode_atts( [ 'id' => 0 ], $atts ) ); return eme_cancel_bookings_form( $id ); } @@ -734,10 +734,10 @@ function eme_add_bookings_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $form_html = __( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -746,20 +746,20 @@ function eme_add_bookings_ajax() { if ( ! isset( $_POST['eme_frontend_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) { $form_html = __( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } if ( empty( $_POST['eme_event_ids'] ) ) { $form_html = __( 'Please select at least one event.', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -769,10 +769,10 @@ function eme_add_bookings_ajax() { if ( empty( $events ) ) { $form_html = __( 'Please select at least one event.', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -785,10 +785,10 @@ function eme_add_bookings_ajax() { if ( ! $captcha_res ) { $form_html = __( 'Please check the hCaptcha box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -798,10 +798,10 @@ function eme_add_bookings_ajax() { if ( ! $captcha_res ) { $form_html = __( 'Please check the Google reCAPTCHA box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -811,10 +811,10 @@ function eme_add_bookings_ajax() { if ( ! $captcha_res ) { $form_html = __( 'You entered an incorrect code', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -830,18 +830,18 @@ function eme_add_bookings_ajax() { if ( has_filter( 'eme_eval_booking_form_post_filter' ) ) { $eval_filter_return = apply_filters( 'eme_eval_booking_form_post_filter', $event ); } else { - $eval_filter_return = array( + $eval_filter_return = [ 0 => 1, 1 => '', - ); + ]; } } elseif ( has_filter( 'eme_eval_multibooking_form_post_filter' ) ) { $eval_filter_return = apply_filters( 'eme_eval_multibooking_form_post_filter', $events ); } else { - $eval_filter_return = array( + $eval_filter_return = [ 0 => 1, 1 => '', - ); + ]; } if ( is_array( $eval_filter_return ) && ! $eval_filter_return[0] ) { // the result of own eval rules failed, so let's use that as a result @@ -893,21 +893,21 @@ function eme_add_bookings_ajax() { $message = eme_replace_booking_placeholders( $message, $event, $booking, $is_multi ); $form_result_message .= '
    ' . $message; echo wp_json_encode( - array( + [ 'Result' => 'OK', 'keep_form' => 0, 'htmlmessage' => $form_result_message, - ) + ] ); } elseif ( $pg_count == 1 && get_option( 'eme_pg_submit_immediately' ) ) { $payment_form = eme_payment_form( $payment_id ); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'keep_form' => 0, 'htmlmessage' => $form_result_message, 'paymentform' => $payment_form, - ) + ] ); } elseif ( get_option( 'eme_payment_redirect' ) ) { $payment = eme_get_payment( $payment_id ); @@ -919,23 +919,23 @@ function eme_add_bookings_ajax() { $form_result_message .= '
    ' . $redirect_msg; } echo wp_json_encode( - array( + [ 'Result' => 'OK', 'keep_form' => 0, 'htmlmessage' => $form_result_message, 'waitperiod' => $waitperiod, 'paymentredirect' => $payment_url, - ) + ] ); } else { $payment_form = eme_payment_form( $payment_id ); echo wp_json_encode( - array( + [ 'Result' => 'OK', 'keep_form' => 0, 'htmlmessage' => $form_result_message, 'paymentform' => $payment_form, - ) + ] ); } } else { @@ -949,19 +949,19 @@ function eme_add_bookings_ajax() { } if ( ! $only_if_not_registered && get_option( 'eme_rsvp_show_form_after_booking' ) ) { echo wp_json_encode( - array( + [ 'Result' => 'OK', 'keep_form' => 1, 'htmlmessage' => $form_result_message, - ) + ] ); } else { echo wp_json_encode( - array( + [ 'Result' => 'OK', 'keep_form' => 0, 'htmlmessage' => $form_result_message, - ) + ] ); } } @@ -978,28 +978,28 @@ function eme_add_bookings_ajax() { } if ( ! $only_if_not_registered && get_option( 'eme_rsvp_show_form_after_booking' ) ) { echo wp_json_encode( - array( + [ 'Result' => 'OK', 'keep_form' => 1, 'htmlmessage' => $form_result_message, - ) + ] ); } else { echo wp_json_encode( - array( + [ 'Result' => 'OK', 'keep_form' => 0, 'htmlmessage' => $form_result_message, - ) + ] ); } } else { // booking failed echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_result_message, - ) + ] ); } wp_die(); @@ -1013,10 +1013,10 @@ function eme_cancel_bookings_ajax() { if ( ! isset( $_POST['honeypot_check'] ) || ! empty( $_POST['honeypot_check'] ) ) { $form_html = __( "Bot detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -1025,10 +1025,10 @@ function eme_cancel_bookings_ajax() { if ( ! isset( $_POST['eme_frontend_nonce'] ) || ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) { $form_html = __( "Form tampering detected. If you believe you've received this message in error please contact the site owner.", 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -1037,10 +1037,10 @@ function eme_cancel_bookings_ajax() { if ( ! $event_id ) { $form_html = __( 'No event id detected', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -1049,10 +1049,10 @@ function eme_cancel_bookings_ajax() { if ( empty( $event ) ) { $form_html = __( 'No event id detected', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -1062,10 +1062,10 @@ function eme_cancel_bookings_ajax() { if ( ! eme_check_hcaptcha() ) { $form_html = __( 'Please check the hCaptcha box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -1074,10 +1074,10 @@ function eme_cancel_bookings_ajax() { if ( ! eme_check_recaptcha() ) { $form_html = __( 'Please check the Google reCAPTCHA box', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -1086,10 +1086,10 @@ function eme_cancel_bookings_ajax() { if ( ! eme_check_captcha( 1 ) ) { $form_html = __( 'You entered an incorrect code', 'events-made-easy' ); echo wp_json_encode( - array( + [ 'Result' => 'NOK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } @@ -1097,7 +1097,7 @@ function eme_cancel_bookings_ajax() { $registration_wp_users_only = $event['registration_wp_users_only']; - $booking_ids = array(); + $booking_ids = []; if ( $registration_wp_users_only || $event['event_status'] == EME_EVENT_STATUS_PRIVATE || $event['event_status'] == EME_EVENT_STATUS_DRAFT ) { // we require a user to be WP registered to be able to book if ( is_user_logged_in() ) { @@ -1142,17 +1142,17 @@ function eme_cancel_bookings_ajax() { $form_html = __( 'There are no bookings associated to this name and email', 'events-made-easy' ); } echo wp_json_encode( - array( + [ 'Result' => 'OK', 'htmlmessage' => $form_html, - ) + ] ); wp_die(); } function eme_multibook_seats( $events, $send_mail, $format, $is_multibooking = 1, $simple = 0 ) { $eme_is_admin_request = eme_is_admin_request(); - $booking_ids = array(); + $booking_ids = []; $form_html = ''; if ( $eme_is_admin_request && get_option( 'eme_rsvp_admin_allow_overbooking' ) ) { $allow_overbooking = 1; @@ -1164,26 +1164,26 @@ function eme_multibook_seats( $events, $send_mail, $format, $is_multibooking = 1 ( isset( $_POST['eme_admin_nonce'] ) && ! wp_verify_nonce( eme_sanitize_request($_POST['eme_admin_nonce']), 'eme_admin' ) ) || ( isset( $_POST['eme_frontend_nonce'] ) && ! wp_verify_nonce( eme_sanitize_request($_POST['eme_frontend_nonce']), 'eme_frontend' ) ) ) { $form_html = __( 'Access denied!', 'events-made-easy' ); - return array( + return [ 0 => $form_html, 1 => $booking_ids, - ); + ]; } $event = $events[0]; if ( ! eme_is_empty_string( $event['event_properties']['rsvp_password'] ) && ! $eme_is_admin_request ) { if ( ! isset( $_POST['rsvp_password'] ) ) { $form_html = __( 'Password is missing', 'events-made-easy' ); - return array( + return [ 0 => $form_html, 1 => $booking_ids, - ); + ]; } elseif ( eme_sanitize_request($_POST['rsvp_password']) != $event['event_properties']['rsvp_password'] ) { $form_html = __( 'Incorrect password given', 'events-made-easy' ); - return array( + return [ 0 => $form_html, 1 => $booking_ids, - ); + ]; } } @@ -1322,7 +1322,7 @@ function eme_multibook_seats( $events, $send_mail, $format, $is_multibooking = 1 // check all required fields if ( get_option( 'eme_rsvp_check_required_fields' ) ) { $all_required_fields = eme_find_required_formfields( $format ); - $missing_required_fields = array(); + $missing_required_fields = []; $eme_address1_string = get_option( 'eme_address1_string' ); $eme_address2_string = get_option( 'eme_address2_string' ); foreach ( $all_required_fields as $required_field ) { @@ -1431,10 +1431,10 @@ function eme_multibook_seats( $events, $send_mail, $format, $is_multibooking = 1 if ( has_filter( 'eme_eval_booking_filter' ) ) { $eval_filter_return = apply_filters( 'eme_eval_booking_filter', $event ); } else { - $eval_filter_return = array( + $eval_filter_return = [ 0 => 1, 1 => '', - ); + ]; } if ( ! eme_is_multi( $min_allowed ) && $bookedSeats < $min_allowed ) { @@ -1566,10 +1566,10 @@ function eme_multibook_seats( $events, $send_mail, $format, $is_multibooking = 1 $payment_id = 0; } - $res = array( + $res = [ 0 => $form_html, 1 => $payment_id, - ); + ]; return $res; } @@ -1582,7 +1582,7 @@ function eme_book_seats( $event, $send_mail ) { } else { $format = eme_nl2br_save_html( get_option( 'eme_registration_form_format' ) ); } - $events = array( 0 => $event ); + $events = [ 0 => $event ]; $is_multibooking = 0; return eme_multibook_seats( $events, $send_mail, $format, $is_multibooking ); } @@ -1596,12 +1596,12 @@ function eme_get_booking( $booking_id ) { if ( eme_is_serialized( $booking['dcodes_used'] ) ) { $booking['dcodes_used'] = eme_unserialize( $booking['dcodes_used'] ); } else { - $booking['dcodes_used'] = array(); + $booking['dcodes_used'] = []; } if ( eme_is_serialized( $booking['dcodes_entered'] ) ) { $booking['dcodes_entered'] = eme_unserialize( $booking['dcodes_entered'] ); } else { - $booking['dcodes_entered'] = array(); + $booking['dcodes_entered'] = []; } } return $booking; @@ -1653,12 +1653,12 @@ function eme_get_bookings_by_wp_id( $wp_id, $scope, $rsvp_status = 0, $paid_stat if ( eme_is_serialized( $booking['dcodes_used'] ) ) { $booking['dcodes_used'] = eme_unserialize( $booking['dcodes_used'] ); } else { - $booking['dcodes_used'] = array(); + $booking['dcodes_used'] = []; } if ( eme_is_serialized( $booking['dcodes_entered'] ) ) { $booking['dcodes_entered'] = eme_unserialize( $booking['dcodes_entered'] ); } else { - $booking['dcodes_entered'] = array(); + $booking['dcodes_entered'] = []; } $bookings[ $key ] = $booking; } @@ -1697,7 +1697,7 @@ function eme_get_pending_booking_ids_by_bookingids( $booking_ids ) { $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $ids_arr = explode(',', $booking_ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "SELECT booking_id FROM $bookings_table WHERE booking_id IN ($commaDelimitedPlaceholders) AND status IN (%d,%d)", array_merge($ids_arr,array(EME_RSVP_STATUS_PENDING,EME_RSVP_STATUS_USERPENDING),$ids_arr)); + $sql = $wpdb->prepare( "SELECT booking_id FROM $bookings_table WHERE booking_id IN ($commaDelimitedPlaceholders) AND status IN (%d,%d)", array_merge($ids_arr, [EME_RSVP_STATUS_PENDING,EME_RSVP_STATUS_USERPENDING], $ids_arr)); return $wpdb->get_col( $sql ); } function eme_get_unpaid_booking_ids_by_bookingids( $booking_ids ) { @@ -1735,7 +1735,7 @@ function eme_get_booked_multiseats_by_wp_event_id( $wp_id, $event_id ) { $persons_table = $eme_db_prefix . PEOPLE_TBNAME; $sql = $wpdb->prepare( "SELECT booking_seats_mp FROM $bookings_table AS bookings LEFT JOIN $persons_table AS people ON bookings.person_id=people.person_id WHERE bookings.status IN (%d,%d,%d) AND people.wp_id = %d AND bookings.event_id = %d", EME_RSVP_STATUS_PENDING, EME_RSVP_STATUS_USERPENDING, EME_RSVP_STATUS_APPROVED, $wp_id, $event_id ); $booking_seats_mp = $wpdb->get_col( $sql ); - $result = array(); + $result = []; foreach ( $booking_seats_mp as $booked_seats ) { $multiseats = eme_convert_multi2array( $booked_seats ); foreach ( $multiseats as $key => $value ) { @@ -1764,7 +1764,7 @@ function eme_get_booked_multiseats_by_person_event_id( $person_id, $event_id ) { $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $sql = $wpdb->prepare( "SELECT booking_seats_mp FROM $bookings_table WHERE status IN (%d,%d,%d) AND person_id = %d AND event_id = %d", EME_RSVP_STATUS_PENDING, EME_RSVP_STATUS_USERPENDING, EME_RSVP_STATUS_APPROVED, $person_id, $event_id ); $booking_seats_mp = $wpdb->get_col( $sql ); - $result = array(); + $result = []; foreach ( $booking_seats_mp as $booked_seats ) { $multiseats = eme_convert_multi2array( $booked_seats ); foreach ( $multiseats as $key => $value ) { @@ -1788,7 +1788,7 @@ function eme_get_event_id_by_booking_id( $booking_id ) { function eme_get_event_by_booking_id( $booking_id ) { $event_id = eme_get_event_id_by_booking_id( $booking_id ); - $event = array(); + $event = []; if ( $event_id ) { $event = eme_get_event( $event_id ); } @@ -1856,8 +1856,8 @@ function eme_db_insert_booking( $event, $booker, $booking ) { // API function so people easily get the booking answers from a post, primarily used for discounts // we use $booking as a var because in discount functions this is also the main var function eme_get_booking_post_answers( $booking, $include_dynamicdata = 1 ) { - $answers = array(); - $fields_seen = array(); + $answers = []; + $fields_seen = []; $event_id = $booking['event_id']; // first do the booking answers per event if any @@ -1881,7 +1881,7 @@ function eme_get_booking_post_answers( $booking, $include_dynamicdata = 1 ) { } else { $value = eme_sanitize_request( $value ); } - $answer = array( + $answer = [ 'field_name' => $formfield['field_name'], 'field_id' => $field_id, 'field_purpose' => $formfield['field_purpose'], @@ -1889,7 +1889,7 @@ function eme_get_booking_post_answers( $booking, $include_dynamicdata = 1 ) { 'answer' => $value, 'grouping_id' => 0, 'occurence_id' => 0, - ); + ]; $answers[] = $answer; } } @@ -1922,15 +1922,15 @@ function eme_get_booking_post_answers( $booking, $include_dynamicdata = 1 ) { } else { $value = eme_sanitize_request( $value ); } - $answer = array( + $answer = [ 'field_name' => $formfield['field_name'], 'field_id' => $field_id, 'field_purpose' => $formfield['field_purpose'], 'extra_charge' => $formfield['extra_charge'], 'answer' => $value, - 'grouping_id' => $group_id, - 'occurence_id' => $occurence_id, - ); + 'grouping_id' => intval($group_id), + 'occurence_id' => intval($occurence_id), + ]; $answers[] = $answer; } } @@ -1961,7 +1961,7 @@ function eme_get_booking_post_answers( $booking, $include_dynamicdata = 1 ) { } else { $value = eme_sanitize_request( $value ); } - $answer = array( + $answer = [ 'field_name' => $formfield['field_name'], 'field_id' => $field_id, 'field_purpose' => $formfield['field_purpose'], @@ -1969,7 +1969,7 @@ function eme_get_booking_post_answers( $booking, $include_dynamicdata = 1 ) { 'answer' => $value, 'grouping_id' => 0, 'occurence_id' => 0, - ); + ]; $answers[] = $answer; } } @@ -1982,7 +1982,7 @@ function eme_booking_answers( $booking, $do_update = 1 ) { } function eme_store_booking_answers( $booking, $do_update = 1 ) { global $wpdb,$eme_db_prefix; - $fields_seen = array(); + $fields_seen = []; if ( empty( $booking['booking_id'] ) ) { $do_update = 0; } @@ -1990,7 +1990,7 @@ function eme_store_booking_answers( $booking, $do_update = 1 ) { $extra_charge = 0; $event_id = $booking['event_id']; $person_id = $booking['person_id']; - $all_answers = array(); + $all_answers = []; if ( $do_update ) { $booking_id = $booking['booking_id']; if ( $booking_id > 0 ) { @@ -2004,7 +2004,7 @@ function eme_store_booking_answers( $booking, $do_update = 1 ) { $booking_id = 0; } - $answer_ids_seen = array(); + $answer_ids_seen = []; $found_answers = eme_get_booking_post_answers( $booking ); foreach ( $found_answers as $answer ) { if ( $answer['extra_charge'] && is_numeric( $answer['answer'] ) ) { @@ -2096,7 +2096,7 @@ function eme_trash_person_bookings_future_events( $person_ids ) { $today = $eme_date_obj_now->getDateTime(); $ids_arr = explode(',', $person_ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "UPDATE $bookings_table SET status = %d WHERE person_id IN ($commaDelimitedPlaceholders) AND event_id IN (SELECT event_id from $events_table WHERE event_end >= %s)", array_merge(array(EME_RSVP_STATUS_TRASH),$ids_arr,array($today))); + $sql = $wpdb->prepare( "UPDATE $bookings_table SET status = %d WHERE person_id IN ($commaDelimitedPlaceholders) AND event_id IN (SELECT event_id from $events_table WHERE event_end >= %s)", array_merge([EME_RSVP_STATUS_TRASH], $ids_arr, [$today])); $wpdb->query( $sql ); } @@ -2106,9 +2106,9 @@ function eme_delete_person_bookings( $person_ids ) { $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $ids_arr = explode(',', $person_ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("DELETE FROM $answers_table WHERE type='booking' AND related_id IN (SELECT booking_id from $bookings_table WHERE person_id IN ($commaDelimitedPlaceholders))",$ids_arr); + $sql = $wpdb->prepare("DELETE FROM $answers_table WHERE type='booking' AND related_id IN (SELECT booking_id from $bookings_table WHERE person_id IN ($commaDelimitedPlaceholders))", $ids_arr); $wpdb->query( $sql ); - $sql = $wpdb->prepare("DELETE FROM $bookings_table WHERE person_id IN ($commaDelimitedPlaceholders)",$ids_arr); + $sql = $wpdb->prepare("DELETE FROM $bookings_table WHERE person_id IN ($commaDelimitedPlaceholders)", $ids_arr); $wpdb->query( $sql ); } @@ -2117,7 +2117,7 @@ function eme_transfer_person_bookings( $person_ids, $to_person_id ) { $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $ids_arr = explode(',', $person_ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("UPDATE $bookings_table SET person_id = %d WHERE person_id IN ($commaDelimitedPlaceholders)",array_merge(array($to_person_id),$ids_arr)); + $sql = $wpdb->prepare("UPDATE $bookings_table SET person_id = %d WHERE person_id IN ($commaDelimitedPlaceholders)", array_merge([$to_person_id], $ids_arr)); return $wpdb->query( $sql ); } @@ -2126,7 +2126,7 @@ function eme_trash_bookings_for_event_ids( $ids ) { $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $ids_arr = explode(',', $ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("UPDATE $bookings_table SET status = %d WHERE event_id IN ($commaDelimitedPlaceholders)",array_merge(array(EME_RSVP_STATUS_TRASH),$ids_arr)); + $sql = $wpdb->prepare("UPDATE $bookings_table SET status = %d WHERE event_id IN ($commaDelimitedPlaceholders)", array_merge([EME_RSVP_STATUS_TRASH], $ids_arr)); $wpdb->query( $sql ); } @@ -2137,8 +2137,8 @@ function eme_trash_booking( $booking_id ) { $booking = eme_get_booking( $line['booking_id'] ); do_action( 'eme_trash_rsvp_action', $booking ); } - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking_id; $fields['status'] = EME_RSVP_STATUS_TRASH; $res = $wpdb->update( $bookings_table, $fields, $where ); @@ -2178,8 +2178,8 @@ function eme_partial_payment_booking( $booking, $amount ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking['booking_id']; $price = eme_get_total_booking_price( $booking ); if ( empty( $booking['received'] ) ) { @@ -2209,8 +2209,8 @@ function eme_mark_booking_paid( $booking, $pg = '', $pg_pid = '' ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking['booking_id']; $fields['booking_paid'] = 1; $fields['pg'] = $pg; @@ -2233,8 +2233,8 @@ function eme_mark_booking_unpaid( $booking ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking['booking_id']; $fields['booking_paid'] = 0; $price = eme_get_total_booking_price( $booking ); @@ -2255,8 +2255,8 @@ function eme_mark_booking_paid_approved( $booking, $pg = '', $pg_pid = '' ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking['booking_id']; $where['waitinglist'] = 0; $fields['booking_paid'] = 1; @@ -2281,7 +2281,7 @@ function eme_mark_booking_pending( $booking_id ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); + $where = []; $where['booking_id'] = $booking_id; $fields['status'] = EME_RSVP_STATUS_PENDING; $fields['waitinglist'] = 0; @@ -2297,7 +2297,7 @@ function eme_set_booking_reminder( $booking_id ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); + $where = []; $where['booking_id'] = $booking_id; $fields['reminder'] = current_time( 'timestamp' ); $res = $wpdb->update( $bookings_table, $fields, $where ); @@ -2312,8 +2312,8 @@ function eme_remove_from_waitinglist( $booking_id ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking_id; $fields['waitinglist'] = 0; $res = $wpdb->update( $bookings_table, $fields, $where ); @@ -2328,8 +2328,8 @@ function eme_move_on_waitinglist( $booking_id ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking_id; $fields['waitinglist'] = 1; $fields['status'] = EME_RSVP_STATUS_PENDING; @@ -2346,7 +2346,7 @@ function eme_mark_booking_userconfirm( $booking_ids ) { $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $ids_arr = explode(',', $booking_ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "UPDATE $bookings_table SET status=%d WHERE booking_id IN ($commaDelimitedPlaceholders)", array_merge(array(EME_RSVP_STATUS_USERPENDING),$ids_arr) ); + $sql = $wpdb->prepare( "UPDATE $bookings_table SET status=%d WHERE booking_id IN ($commaDelimitedPlaceholders)", array_merge([EME_RSVP_STATUS_USERPENDING], $ids_arr) ); $wpdb->query( $sql ); } @@ -2379,8 +2379,8 @@ function eme_approve_booking( $booking_id ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['booking_id'] = $booking_id; $fields['waitinglist'] = 0; $fields['status'] = EME_RSVP_STATUS_APPROVED; @@ -2395,7 +2395,7 @@ function eme_approve_booking( $booking_id ) { function eme_db_update_booking( $line ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $where = array(); + $where = []; $where['booking_id'] = $line['booking_id']; $line['modif_date'] = current_time( 'mysql', false ); // make sure we don't disturb the discount fields for now, that calc is done later @@ -2455,17 +2455,17 @@ function eme_get_available_multiseats( $event_id, $exclude_waiting_list = 0, $ex return 0; } $multiseats = eme_convert_multi2array( $event['event_seats'] ); - $available_seats = array(); + $available_seats = []; if ( $event['event_properties']['ignore_pending'] == 1 ) { $used_multiseats = eme_get_approved_multiseats( $event_id ); if ( eme_event_has_pgs_configured( $event ) ) { $young_pending_multiseats = eme_get_young_pending_multiseats( $event_id, $exclude_pending_booking_id ); } else { - $young_pending_multiseats = array(); + $young_pending_multiseats = []; } } else { $used_multiseats = eme_get_booked_multiseats( $event_id, $exclude_waiting_list ); - $young_pending_multiseats = array(); + $young_pending_multiseats = []; } foreach ( $multiseats as $key => $value ) { if ( isset( $used_multiseats[ $key ] ) ) { @@ -2520,7 +2520,7 @@ function eme_get_booked_multiseats( $event_id, $exclude_waiting_list = 0, $only_ $waiting = ( $only_waiting_list == 1 ) ? 'AND waitinglist=1' : ''; $sql = $wpdb->prepare( "SELECT booking_seats_mp FROM $bookings_table WHERE status IN (%d,%d,%d) AND event_id = %d $exclude $waiting", EME_RSVP_STATUS_PENDING, EME_RSVP_STATUS_USERPENDING, EME_RSVP_STATUS_APPROVED, $event_id ); $booking_seats_mp = $wpdb->get_col( $sql ); - $result = array(); + $result = []; foreach ( $booking_seats_mp as $booked_seats ) { if ( empty( $booked_seats ) ) { continue; @@ -2560,7 +2560,7 @@ function eme_get_paid_multiseats( $event_id ) { $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $sql = $wpdb->prepare( "SELECT booking_seats_mp FROM $bookings_table WHERE status IN (%d,%d,%d) AND event_id = %d and booking_paid=1", EME_RSVP_STATUS_PENDING, EME_RSVP_STATUS_USERPENDING, EME_RSVP_STATUS_APPROVED, $event_id ); $booking_seats_mp = $wpdb->get_col( $sql ); - $result = array(); + $result = []; foreach ( $booking_seats_mp as $booked_seats ) { $multiseats = eme_convert_multi2array( $booked_seats ); foreach ( $multiseats as $key => $value ) { @@ -2589,7 +2589,7 @@ function eme_get_approved_multiseats( $event_id ) { $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $sql = $wpdb->prepare( "SELECT booking_seats_mp FROM $bookings_table WHERE status=%d AND event_id = %d", EME_RSVP_STATUS_APPROVED, $event_id ); $booking_seats_mp = $wpdb->get_col( $sql ); - $result = array(); + $result = []; foreach ( $booking_seats_mp as $booked_seats ) { $multiseats = eme_convert_multi2array( $booked_seats ); foreach ( $multiseats as $key => $value ) { @@ -2663,7 +2663,7 @@ function eme_get_pending_multiseats( $event_id, $old_date = '', $exclude_booking } $sql = $wpdb->prepare( "SELECT booking_seats_mp FROM $bookings_table WHERE status IN (%d,%d) AND event_id = %d $younger_than $exclude_booking", EME_RSVP_STATUS_PENDING, EME_RSVP_STATUS_USERPENDING, $event_id ); $booking_seats_mp = $wpdb->get_col( $sql ); - $result = array(); + $result = []; foreach ( $booking_seats_mp as $booked_seats ) { $multiseats = eme_convert_multi2array( $booked_seats ); foreach ( $multiseats as $key => $value ) { @@ -2760,12 +2760,12 @@ function eme_get_bookings_for( $event_ids, $rsvp_status = 0, $paid_status = 0 ) $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $people_table = $eme_db_prefix . PEOPLE_TBNAME; - $bookings = array(); + $bookings = []; if ( ! $event_ids ) { return $bookings; } - $where = array(); + $where = []; if ( is_array( $event_ids ) && eme_array_integers( $event_ids ) ) { $where[] = 'bookings.event_id IN (' . join( ',', $event_ids ) . ')'; } elseif ( is_numeric( $event_ids ) ) { @@ -2794,7 +2794,7 @@ function eme_get_bookings_for_event_wp_id( $event_id, $wp_id ) { $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; $people_table = $eme_db_prefix . PEOPLE_TBNAME; - $bookings = array(); + $bookings = []; if ( ! $event_id || ! $wp_id ) { return $bookings; } @@ -2811,14 +2811,14 @@ function eme_get_booking_personids( $booking_ids ) { } $ids_arr = explode(',', $booking_ids ); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare("SELECT DISTINCT person_id FROM $bookings_table WHERE booking_id IN ($commaDelimitedPlaceholders)",$ids_arr); + $sql = $wpdb->prepare("SELECT DISTINCT person_id FROM $bookings_table WHERE booking_id IN ($commaDelimitedPlaceholders)", $ids_arr); return $wpdb->get_col( $sql ); } function eme_get_bookings_by_paymentid( $payment_id ) { global $wpdb,$eme_db_prefix; $bookings_table = $eme_db_prefix . BOOKINGS_TBNAME; - $bookings = array(); + $bookings = []; if ( ! $payment_id ) { return $bookings; } @@ -2828,12 +2828,12 @@ function eme_get_bookings_by_paymentid( $payment_id ) { if ( eme_is_serialized( $booking['dcodes_used'] ) ) { $booking['dcodes_used'] = eme_unserialize( $booking['dcodes_used'] ); } else { - $booking['dcodes_used'] = array(); + $booking['dcodes_used'] = []; } if ( eme_is_serialized( $booking['dcodes_entered'] ) ) { $booking['dcodes_entered'] = eme_unserialize( $booking['dcodes_entered'] ); } else { - $booking['dcodes_entered'] = array(); + $booking['dcodes_entered'] = []; } $bookings[ $key ] = $booking; } @@ -2923,7 +2923,7 @@ function eme_get_attendees( $event_id, $rsvp_status = 0, $paid_status = 0 ) { if ( $person_ids ) { $attendees = eme_get_persons( $person_ids ); } else { - $attendees = array(); + $attendees = []; } return $attendees; } @@ -3075,10 +3075,10 @@ function eme_replace_booking_placeholders( $format, $event, $booking, $is_multib if ( $booking['person_id'] == -1 ) { // -1 ? then this is from a fake booking $person = eme_add_update_person_from_form( 0, '', '', '', 0, 0, 1 ); - $person_answers = array(); + $person_answers = []; $booking_answers = eme_get_booking_post_answers( $booking, 0 ); // add the 0-option to exclude dynamic answers - $dyn_answers = array(); - $files = array(); + $dyn_answers = []; + $files = []; } else { $person = eme_get_person( $booking['person_id'] ); if ( $take_answers_from_post ) { @@ -3087,7 +3087,7 @@ function eme_replace_booking_placeholders( $format, $event, $booking, $is_multib $booking_answers = eme_get_nodyndata_booking_answers( $booking['booking_id'] ); } $person_answers = eme_get_person_answers( $booking['person_id'] ); - $dyn_answers = ( isset( $event['event_properties']['rsvp_dyndata'] ) ) ? eme_get_dyndata_booking_answers( $booking['booking_id'] ) : array(); + $dyn_answers = ( isset( $event['event_properties']['rsvp_dyndata'] ) ) ? eme_get_dyndata_booking_answers( $booking['booking_id'] ) : []; $files = eme_get_uploaded_files( $booking['booking_id'], 'bookings' ); } if ( ! $person ) { @@ -3257,7 +3257,7 @@ function eme_replace_booking_placeholders( $format, $event, $booking, $is_multib } elseif ( preg_match( '/#_APPLIEDDISCOUNTNAMES$/', $result ) ) { if ( ! empty( $booking['discountids'] ) ) { $discount_ids = explode( ',', $booking['discountids'] ); - $discount_names = array(); + $discount_names = []; foreach ( $discount_ids as $discount_id ) { $discount = eme_get_discount( $discount_id ); if ( $discount && isset( $discount['name'] ) ) { @@ -3440,9 +3440,9 @@ function eme_replace_booking_placeholders( $format, $event, $booking, $is_multib $targetBasePath = EME_UPLOAD_DIR . '/bookings/' . $booking['booking_id']; $targetBaseUrl = EME_UPLOAD_URL . '/bookings/' . $booking['booking_id']; $url_to_encode = eme_check_rsvp_url( $payment, $booking['booking_id'] ); - list($target_file,$target_url) = eme_generate_qrcode( $url_to_encode, $targetBasePath, $targetBaseUrl, $size ); + [$target_file, $target_url] = eme_generate_qrcode( $url_to_encode, $targetBasePath, $targetBaseUrl, $size ); if ( is_file( $target_file ) ) { - list($width, $height, $type, $attr) = getimagesize( $target_file ); + [$width, $height, $type, $attr] = getimagesize( $target_file ); $replacement = ""; } } elseif ( $payment && preg_match( '/#_ATTENDANCE_URL$/', $result ) ) { @@ -3479,7 +3479,7 @@ function eme_replace_booking_placeholders( $format, $event, $booking, $is_multib } elseif ( $payment && preg_match( '/#_CANCEL_CODE$/', $result ) ) { $replacement = $payment['random_id']; } elseif ( preg_match( '/#_FILES/', $result ) ) { - $res_files = array(); + $res_files = []; foreach ( $files as $file ) { if ( $target == 'html' ) { $res_files[] = eme_get_uploaded_file_html( $file ); @@ -3559,7 +3559,7 @@ function eme_replace_booking_placeholders( $format, $event, $booking, $is_multib $sep = '||'; } $formfield = eme_get_formfield( $field_key ); - if ( ! empty( $formfield ) && in_array( $formfield['field_purpose'], array( 'generic', 'rsvp' ) ) ) { + if ( ! empty( $formfield ) && in_array( $formfield['field_purpose'], [ 'generic', 'rsvp' ] ) ) { $field_id = $formfield['field_id']; $field_replace = ''; foreach ( $answers as $answer ) { @@ -4192,7 +4192,7 @@ function eme_email_booking_action( $booking, $action, $is_multibooking = 0 ) { // this possibily overrides mail_res, but that's ok since errors for mail to people are more important than to the contact person // to make sure the attachment_ids is an array ... if ( empty( $attachment_ids ) ) { - $attachment_ids_arr = array(); + $attachment_ids_arr = []; } else { $attachment_ids_arr = explode( ',', $attachment_ids ); } @@ -4359,7 +4359,7 @@ function eme_registration_seats_page( $pending = 0 ) { $person = eme_get_person_by_email_only( $email ); } if ( ! $person ) { - $person = array(); + $person = []; $person['lastname'] = $lastname; $person['firstname'] = $firstname; $person['email'] = $email; @@ -4410,7 +4410,7 @@ function eme_registration_seats_page( $pending = 0 ) { $already_booked_seats = eme_get_total( $booking['booking_seats_mp'] ); $booking_prices_mp = eme_convert_multi2array( $booking['event_price'] ); - $bookedSeats_mp = array(); + $bookedSeats_mp = []; // start with the existing mp bookedseats, in case a #_SEATSxx is missing (due to a eme_if condition maybe), it is then not touched foreach ( $booking_prices_mp as $key => $value ) { $bookedSeats_mp[ $key ] = intval( $already_booked_seats_mp[ $key ] ); @@ -4516,7 +4516,7 @@ function eme_import_csv_payments() { $today = $eme_date_obj_now->getDate(); //validate whether uploaded file is a csv file - $csvMimes = array( 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ); + $csvMimes = [ 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain' ]; if ( empty( $_FILES['eme_csv']['name'] ) || ! in_array( $_FILES['eme_csv']['type'], $csvMimes ) ) { return sprintf( __( 'No CSV file detected: %s', 'events-made-easy' ), $_FILES['eme_csv']['type'] ); } @@ -4560,7 +4560,7 @@ function eme_import_csv_payments() { if ( ! in_array( 'payment_date', $headers ) || ! ( in_array( 'unique_nbr', $headers ) || in_array( 'payment_id', $headers ) || in_array( 'payment_randomid', $headers ) ) || ! in_array( 'amount', $headers ) ) { $result = __( 'Not all required fields present.', 'events-made-easy' ); } else { - $empty_props = array(); + $empty_props = []; $empty_props = eme_init_event_props( $empty_props ); // now loop over the rest while ( ( $row = fgetcsv( $handle, 0, $delimiter, $enclosure ) ) !== false ) { @@ -4634,7 +4634,7 @@ function eme_import_csv_payments() { function eme_registration_seats_form_table( $pending = 0, $trash = 0 ) { global $plugin_page, $eme_plugin_url; - $scope_names = array(); + $scope_names = []; $scope_names['past'] = __( 'Past events', 'events-made-easy' ); $scope_names['all'] = __( 'All events', 'events-made-easy' ); $scope_names['future'] = __( 'Future events', 'events-made-easy' ); @@ -4848,9 +4848,9 @@ function eme_registration_seats_form_table( $pending = 0, $trash = 0 ) {

    " . __( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -5671,7 +5673,7 @@ function eme_ajax_action_remove_waitinglist( $ids_arr, $action, $send_mail ) { $action_ok = 0; } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mail_ok && $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -5712,7 +5714,7 @@ function eme_ajax_action_move_waitinglist( $ids_arr, $action, $send_mail, $refun $action_ok = 0; } } - $ajaxResult = array(); + $ajaxResult = []; if ( ! $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'There was a problem executing the desired action, please check your logs.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'ERROR'; @@ -5755,7 +5757,7 @@ function eme_ajax_action_rsvp_aprove( $ids_arr, $action, $send_mail ) { } } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mail_ok && $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -5777,7 +5779,7 @@ function eme_ajax_action_rsvp_delete( $ids_arr ) { $action_ok = 0; } } - $ajaxResult = array(); + $ajaxResult = []; if ( $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -5816,7 +5818,7 @@ function eme_ajax_action_rsvp_trash( $ids_arr, $action, $send_mail, $refund ) { $action_ok = 0; } } - $ajaxResult = array(); + $ajaxResult = []; if ( ! $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'There was a problem executing the desired action, please check your logs.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'ERROR'; @@ -5880,7 +5882,7 @@ function eme_ajax_action_booking_partial_payment( $booking_id, $amount, $send_ma } else { $action_ok = 0; } - $ajaxResult = array(); + $ajaxResult = []; if ( $mail_ok && $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -5922,7 +5924,7 @@ function eme_ajax_action_mark_booking_paid( $ids_arr, $action, $send_mail ) { } } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mail_ok && $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -5961,7 +5963,7 @@ function eme_ajax_action_mark_booking_unpaid( $ids_arr, $action, $send_mail, $re $action_ok = 0; } } - $ajaxResult = array(); + $ajaxResult = []; if ( ! $action_ok ) { if ( $refund ) { $ajaxResult['htmlmessage'] = "

    " . __( 'There was a problem refunding the payment, please check your logs.', 'events-made-easy' ) . '

    '; @@ -6001,7 +6003,7 @@ function eme_ajax_action_send_booking_mails( $ids_arr, $subject_template_id, $bo } } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mail_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'The mail has been sent.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -6021,7 +6023,7 @@ function eme_ajax_action_resend_booking_mail( $ids_arr, $action ) { $mail_ok = 0; } } - $ajaxResult = array(); + $ajaxResult = []; if ( $mail_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'The mail has been sent.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; @@ -6034,7 +6036,7 @@ function eme_ajax_action_resend_booking_mail( $ids_arr, $action ) { function eme_ajax_action_mark_userconfirm( $ids, $action ) { eme_mark_booking_userconfirm( $ids ); - $ajaxResult = array(); + $ajaxResult = []; $ajaxResult['htmlmessage'] = "

    " . __( 'The action has been executed successfully.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'OK'; print wp_json_encode( $ajaxResult ); @@ -6066,7 +6068,7 @@ function eme_ajax_action_mark_pending( $ids_arr, $action, $send_mail, $refund ) $action_ok = 0; } } - $ajaxResult = array(); + $ajaxResult = []; if ( ! $action_ok ) { $ajaxResult['htmlmessage'] = "

    " . __( 'There was a problem executing the desired action, please check your logs.', 'events-made-easy' ) . '

    '; $ajaxResult['Result'] = 'ERROR'; @@ -6102,7 +6104,7 @@ function eme_generate_booking_pdf( $booking, $event, $template_id ) { $orientation = $template['properties']['pdf_orientation']; $pagesize = $template['properties']['pdf_size']; if ( $pagesize == 'custom' ) { - $pagesize = array( 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ); + $pagesize = [ 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ]; } $dompdf->setPaper( $pagesize, $orientation ); @@ -6168,7 +6170,7 @@ function eme_ajax_generate_booking_pdf( $ids_arr, $template_id, $template_id_hea $orientation = $template['properties']['pdf_orientation']; $pagesize = $template['properties']['pdf_size']; if ( $pagesize == 'custom' ) { - $pagesize = array( 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ); + $pagesize = [ 0, 0, $template['properties']['pdf_width'], $template['properties']['pdf_height'] ]; } $dompdf->setPaper( $pagesize, $orientation ); diff --git a/eme-tasks.php b/eme-tasks.php index c6d0a338..269af32a 100644 --- a/eme-tasks.php +++ b/eme-tasks.php @@ -5,7 +5,7 @@ } function eme_new_task() { - $task = array( + $task = [ 'event_id' => 0, 'task_start' => '', 'task_end' => '', @@ -14,13 +14,13 @@ function eme_new_task() { 'task_seq' => 1, 'task_nbr' => 0, 'spaces' => 1, - ); + ]; return $task; } function eme_handle_tasks_post_adminform( $event_id, $day_difference = 0 ) { global $eme_timezone; - $eme_tasks_arr = array(); + $eme_tasks_arr = []; if ( empty( $_POST['eme_tasks'] ) ) { return $eme_tasks_arr; } @@ -102,7 +102,7 @@ function eme_db_update_task_by_task_nbr( $line ) { function eme_db_update_task( $line ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . TASKS_TBNAME; - $where = array(); + $where = []; $where['task_id'] = $line['task_id']; $tmp_task = eme_new_task(); @@ -120,7 +120,7 @@ function eme_db_update_task( $line ) { function eme_db_delete_task( $task_id ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . TASKS_TBNAME; - $wpdb->delete( $table, array( 'task_id' => $task_id ) ); + $wpdb->delete( $table, [ 'task_id' => $task_id ] ); } function eme_delete_event_tasks( $event_id ) { @@ -141,10 +141,10 @@ function eme_delete_event_old_tasks( $event_id, $ids_arr ) { } $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); $table = $eme_db_prefix . TASKS_TBNAME; - $sql = $wpdb->prepare( "DELETE FROM $table WHERE event_id=%d AND task_id NOT IN ( $commaDelimitedPlaceholders )", array_merge(array($event_id),$ids_arr)); + $sql = $wpdb->prepare( "DELETE FROM $table WHERE event_id=%d AND task_id NOT IN ( $commaDelimitedPlaceholders )", array_merge([$event_id], $ids_arr)); $wpdb->query( $sql); $table = $eme_db_prefix . TASK_SIGNUPS_TBNAME; - $sql = $wpdb->prepare( "DELETE FROM $table WHERE event_id=%d AND task_id NOT IN ( $commaDelimitedPlaceholders )", array_merge(array($event_id),$ids_arr)); + $sql = $wpdb->prepare( "DELETE FROM $table WHERE event_id=%d AND task_id NOT IN ( $commaDelimitedPlaceholders )", array_merge([$event_id], $ids_arr)); $wpdb->query( $sql); } @@ -170,7 +170,7 @@ function eme_db_insert_task_signup( $line ) { function eme_db_update_task_signup( $line ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . TASK_SIGNUPS_TBNAME; - $where = array(); + $where = []; $where['id'] = $line['id']; if ( $wpdb->update( $table, $line, $where ) === false ) { $res = false; @@ -183,16 +183,16 @@ function eme_db_update_task_signup( $line ) { function eme_transfer_person_task_signups( $person_ids, $to_person_id ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . TASK_SIGNUPS_TBNAME; - $ids_arr = explode(',',$person_ids); + $ids_arr = explode(',', $person_ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); - $sql = $wpdb->prepare( "UPDATE $table SET person_id = %d WHERE person_id ( $commaDelimitedPlaceholders )", array_merge(array($to_person_id),$ids_arr)); + $sql = $wpdb->prepare( "UPDATE $table SET person_id = %d WHERE person_id ( $commaDelimitedPlaceholders )", array_merge([$to_person_id], $ids_arr)); return $wpdb->query( $sql ); } function eme_db_delete_task_signup( $signup_id ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . TASK_SIGNUPS_TBNAME; - if ( $wpdb->delete( $table, array( 'id' => $signup_id ) ) === false ) { + if ( $wpdb->delete( $table, [ 'id' => $signup_id ] ) === false ) { $res = false; } else { $res = true; @@ -242,7 +242,7 @@ function eme_get_task_signups_by( $wp_id, $task_id = 0, $event_id = 0, $scope = $events_table = $eme_db_prefix . EVENTS_TBNAME; $events_join = "LEFT JOIN $events_table ON $table.event_id=$events_table.event_id"; - $order_arr = array(); + $order_arr = []; if ( empty( $event_id ) ) { $order_arr[] = "$events_table.event_start ASC, $events_table.event_name ASC"; } @@ -256,7 +256,7 @@ function eme_get_task_signups_by( $wp_id, $task_id = 0, $event_id = 0, $scope = } $wp_id = intval( $wp_id ); - $where_arr = array( "$people_table.wp_id=$wp_id" ); + $where_arr = [ "$people_table.wp_id=$wp_id" ]; if ( empty( $event_id ) ) { if ( $scope == 'future' ) { $eme_date_obj_now = new ExpressiveDate( 'now', $eme_timezone ); @@ -282,7 +282,7 @@ function eme_get_task_signups_by( $wp_id, $task_id = 0, $event_id = 0, $scope = function eme_get_tasksignup_personids( $signup_ids ) { global $wpdb,$eme_db_prefix; $table = $eme_db_prefix . TASK_SIGNUPS_TBNAME; - $ids_arr = explode(',',$signup_ids); + $ids_arr = explode(',', $signup_ids); $commaDelimitedPlaceholders = implode(',', array_fill(0, count($ids_arr), '%d')); $sql = $wpdb->prepare( "SELECT DISTINCT person_id FROM $table WHERE id IN ( $commaDelimitedPlaceholders )", $ids_arr); return $wpdb->get_col( $sql ); @@ -293,7 +293,7 @@ function eme_count_event_task_signups( $event_id ) { $table = $eme_db_prefix . TASK_SIGNUPS_TBNAME; $sql = $wpdb->prepare( "SELECT task_id, COUNT(*) as signup_count FROM $table WHERE event_id=%d GROUP BY task_id", $event_id ); $res = $wpdb->get_results( $sql, ARRAY_A ); - $return_arr = array(); + $return_arr = []; foreach ( $res as $row ) { $return_arr[ $row['task_id'] ] = $row['signup_count']; } @@ -430,7 +430,7 @@ function eme_task_signups_table_layout( $message = '' ) { "; + $val = ""; + $val = " '; + $val .= " '; if ( ! $horizontal ) { $val .= "
    \n"; } @@ -516,9 +516,9 @@ function eme_ui_checkbox_binary( $option_value, $name, $label = '', $required = } $name = wp_strip_all_tags( $name ); - $val = ""; + $val = ""; if ( ! empty( $label ) ) { - $val .= "'; + $val .= "'; } return $val; } @@ -550,7 +550,7 @@ function eme_ui_checkbox( $option_value, $name, $list, $horizontal = true, $requ } else { "$key" == $option_value ? $selected = "checked='checked' " : $selected = ''; } - $val .= " '; + $val .= " '; if ( ! $horizontal ) { $val .= "
    \n"; } @@ -561,6 +561,6 @@ function eme_ui_checkbox( $option_value, $name, $list, $horizontal = true, $requ function eme_ui_number( $option_value, $name ) { $name = wp_strip_all_tags( $name ); - return ""; + return ""; } ?> diff --git a/eme-widgets.php b/eme-widgets.php index 7b23ce79..a53163e4 100644 --- a/eme-widgets.php +++ b/eme-widgets.php @@ -11,11 +11,11 @@ class WP_Widget_eme_list extends WP_Widget { - function __construct() { + public function __construct() { parent::__construct( - 'eme_list', // Base ID + 'eme_list', // Base ID __( 'Events Made Easy List of events', 'events-made-easy' ), // Name - array( 'description' => __( 'Events Made Easy List of events', 'events-made-easy' ) ) // Args + [ 'description' => __( 'Events Made Easy List of events', 'events-made-easy' ) ] // Args ); } @@ -90,10 +90,10 @@ public function update( $new_instance, $old_instance ) { $instance = array_merge( $old_instance, $new_instance ); $instance['title'] = wp_strip_all_tags( $instance['title'] ); $instance['limit'] = intval( $instance['limit'] ); - if ( ! in_array( $instance['showperiod'], array( 'daily', 'monthly', 'yearly' ) ) ) { + if ( ! in_array( $instance['showperiod'], [ 'daily', 'monthly', 'yearly' ] ) ) { $instance['showperiod'] = ''; } - if ( ! in_array( $instance['order'], array( 'ASC', 'DESC' ) ) ) { + if ( ! in_array( $instance['order'], [ 'ASC', 'DESC' ] ) ) { $instance['order'] = 'ASC'; } return $instance; @@ -102,8 +102,8 @@ public function update( $new_instance, $old_instance ) { public function form( $instance ) { //Defaults $instance = wp_parse_args( - (array) $instance, - array( + (array) $instance, + [ 'limit' => 5, 'scope' => 'future', 'order' => 'ASC', @@ -111,7 +111,7 @@ public function form( $instance ) { 'format_tpl' => 0, 'authorid' => '', 'show_ongoing' => 1, - ) + ] ); $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $format_tpl = isset( $instance['format_tpl'] ) ? intval( $instance['format_tpl'] ) : 0; @@ -131,7 +131,7 @@ public function form( $instance ) { $recurrence_only_once = empty( $instance['recurrence_only_once'] ) ? '' : eme_esc_html( $instance['recurrence_only_once'] ); $authorid = empty( $instance['authorid'] ) ? '' : eme_esc_html( $instance['authorid'] ); $categories = eme_get_categories(); - $option_categories = array(); + $option_categories = []; foreach ( $categories as $cat ) { $id = $cat['category_id']; $option_categories[ $id ] = $cat['category_name']; @@ -208,12 +208,12 @@ public function form( $instance ) {
    esc_attr( $this->get_field_id( 'authorid' ) ), 'name' => esc_attr( $this->get_field_name( 'authorid' ) ), 'show_option_none' => __( 'Select...', 'events-made-easy' ), 'selected' => $authorid, - ) + ] ); ?>

    @@ -242,11 +242,11 @@ public function form( $instance ) { class WP_Widget_eme_calendar extends WP_Widget { - function __construct() { + public function __construct() { parent::__construct( - 'eme_calendar', // Base ID + 'eme_calendar', // Base ID __( 'Events Made Easy Calendar', 'events-made-easy' ), // Name - array( 'description' => __( 'Events Made Easy Calendar', 'events-made-easy' ) ) // Args + [ 'description' => __( 'Events Made Easy Calendar', 'events-made-easy' ) ] // Args ); } @@ -281,7 +281,7 @@ public function widget( $args, $instance ) { $notcategory = implode( '+', $notcategory ); } - $options = array(); + $options = []; $options['title'] = $title; $options['long_events'] = $long_events; $options['category'] = $category; @@ -324,7 +324,7 @@ public function update( $new_instance, $old_instance ) { public function form( $instance ) { //Defaults - $instance = wp_parse_args( (array) $instance, array( 'long_events' => 0 ) ); + $instance = wp_parse_args( (array) $instance, [ 'long_events' => 0 ] ); $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $category = empty( $instance['category'] ) ? '' : eme_esc_html( $instance['category'] ); $notcategory = empty( $instance['notcategory'] ) ? '' : eme_esc_html( $instance['notcategory'] ); @@ -333,7 +333,7 @@ public function form( $instance ) { $holiday_id = isset( $instance['holiday_id'] ) ? intval( $instance['holiday_id'] ) : 0; $categories = eme_get_categories(); $holidays_array_by_id = eme_get_holidays_array_by_id(); - $option_categories = array(); + $option_categories = []; foreach ( $categories as $cat ) { $id = $cat['category_id']; $option_categories[ $id ] = $cat['category_name']; @@ -381,12 +381,12 @@ public function form( $instance ) {
    esc_attr( $this->get_field_id( 'authorid' ) ), 'name' => esc_attr( $this->get_field_name( 'authorid' ) ), 'show_option_none' => __( 'Select...', 'events-made-easy' ), 'selected' => $authorid, - ) + ] ); ?>

    diff --git a/events-manager.php b/events-manager.php index b3f6f920..9cbaa49f 100644 --- a/events-manager.php +++ b/events-manager.php @@ -170,11 +170,11 @@ function eme_plugin_row_meta( $links, $file ) { if ( strpos( $file, 'events-manager.php' ) !== false ) { - $new_links = array( + $new_links = [ 'donate Paypal' => 'Donate (Paypal)', 'donate Liberapay' => 'Donate (Liberapay)', 'Support' => 'Support', - ); + ]; $links = array_merge( $links, $new_links ); } return $links; @@ -182,7 +182,7 @@ function eme_plugin_row_meta( $links, $file ) { add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'eme_add_action_links' ); function eme_add_action_links( $links ) { - $mylinks = array( 'Settings' ); + $mylinks = [ 'Settings' ]; return array_merge( $links, $mylinks ); } @@ -226,7 +226,7 @@ function eme_insertMyRewriteRules( $rules ) { // using pagename as param to index.php causes rewrite troubles if the page is a subpage of another // luckily for us we have the page id, and this works ok $events_page_id = eme_get_events_page_id(); - $newrules = array(); + $newrules = []; $events_prefixes = explode( ',', get_option( 'eme_permalink_events_prefix', 'events' ) ); foreach ( $events_prefixes as $events_prefix ) { if ( eme_is_empty_string( $events_prefix ) ) { @@ -348,9 +348,9 @@ function eme_insertMyRewriteQueryVars( $vars ) { use YahnisElsts\PluginUpdateChecker\v5\PucFactory; $myUpdateChecker = PucFactory::buildUpdateChecker( - 'https://github.com/liedekef/events-made-easy/', - __FILE__, - 'events-made-easy' + 'https://github.com/liedekef/events-made-easy/', + __FILE__, + 'events-made-easy' ); //Set the branch that contains the stable release. @@ -453,7 +453,7 @@ function _eme_install() { } // now cleanup old crons - $crons_to_remove = array( 'eme_cron_cleanup_unpaid', 'eme_cron_cleanup_unconfirmed', 'eme_cron_cleanup_captcha' ); + $crons_to_remove = [ 'eme_cron_cleanup_unpaid', 'eme_cron_cleanup_unconfirmed', 'eme_cron_cleanup_captcha' ]; foreach ( $crons_to_remove as $tmp_cron ) { if ( wp_next_scheduled( $tmp_cron ) ) { wp_unschedule_hook( $tmp_cron ); @@ -461,14 +461,14 @@ function _eme_install() { } // we'll restore some planned actions too, if previously deactivated - $cron_actions = array( 'eme_cron_send_new_events', 'eme_cron_send_queued' ); + $cron_actions = [ 'eme_cron_send_new_events', 'eme_cron_send_queued' ]; foreach ( $cron_actions as $cron_action ) { $schedule = get_option( $cron_action ); // old schedule names are renamed to eme_* if (preg_match( '/^(1min|5min|15min|30min|4weeks)$/', $schedule, $matches ) ) { $res = $matches[0]; $schedule = "eme_".$res; - update_option($cron_action,$schedule); + update_option($cron_action, $schedule); wp_unschedule_hook( $cron_action ); } @@ -515,13 +515,13 @@ function _eme_uninstall( $force_drop = 0 ) { $drop_settings = get_option( 'eme_uninstall_drop_settings' ); // these crons get planned with a fixed schedule at activation time, so we don't need to store their planned setting when deactivating - $cron_actions1 = array( 'eme_cron_daily_actions', 'eme_cron_cleanup_captcha' ); + $cron_actions1 = [ 'eme_cron_daily_actions', 'eme_cron_cleanup_captcha' ]; foreach ( $cron_actions1 as $cron_action ) { if ( wp_next_scheduled( $cron_action ) ) { wp_unschedule_hook( $cron_action ); } } - $cron_actions2 = array( 'eme_cron_cleanup_unpaid', 'eme_cron_send_new_events', 'eme_cron_send_queued' ); + $cron_actions2 = [ 'eme_cron_cleanup_unpaid', 'eme_cron_send_new_events', 'eme_cron_send_queued' ]; foreach ( $cron_actions2 as $cron_action ) { // if the action is planned, keep the planning in an option (if we're not clearing all data) and then clear the planning if ( wp_next_scheduled( $cron_action ) ) { @@ -926,15 +926,15 @@ function eme_create_locations_table( $charset, $collate, $db_version ) { maybe_create_table( $table_name, $sql ); $wpdb->query( - 'INSERT INTO ' . $table_name . " (location_name, location_address1, location_city, location_latitude, location_longitude) + 'INSERT INTO ' . $table_name . " (location_name, location_address1, location_city, location_latitude, location_longitude) VALUES ('Arts Millenium Building', 'Newcastle Road','Galway', '53.275', '-9.06532')" ); $wpdb->query( - 'INSERT INTO ' . $table_name . " (location_name, location_address1, location_city, location_latitude, location_longitude) + 'INSERT INTO ' . $table_name . " (location_name, location_address1, location_city, location_latitude, location_longitude) VALUES ('The Crane Bar', '2, Sea Road','Galway', '53.2683224', '-9.0626223')" ); $wpdb->query( - 'INSERT INTO ' . $table_name . " (location_name, location_address1, location_city, location_latitude, location_longitude) + 'INSERT INTO ' . $table_name . " (location_name, location_address1, location_city, location_latitude, location_longitude) VALUES ('Taaffes Bar', '19 Shop Street','Galway', '53.2725', '-9.05321')" ); } else { @@ -1254,8 +1254,8 @@ function eme_create_categories_table( $charset, $collate, $db_version ) { if ( $db_version < 66 ) { $categories = $wpdb->get_results( "SELECT * FROM $table_name", ARRAY_A ); foreach ( $categories as $this_category ) { - $where = array(); - $fields = array(); + $where = []; + $fields = []; $where['category_id'] = $this_category['category_id']; $fields['category_slug'] = eme_permalink_convert_noslash( $this_category['category_name'] ); $wpdb->update( $table_name, $fields, $where ); @@ -1954,14 +1954,14 @@ function eme_create_attendances_table( $charset, $collate, $db_version ) { function eme_create_events_page() { global $wpdb,$eme_db_prefix; - $postarr = array( + $postarr = [ 'post_title' => wp_strip_all_tags( __( 'Events', 'events-made-easy' ) ), 'post_content' => __( "This page is used by Events Made Easy. Don't change it, don't use it in your menu's, don't delete it. Just make sure the EME setting called 'Events page' points to this page. EME uses this page to render any and all events, locations, bookings, maps, ... anything. If you do want to delete this page, create a new one EME can use and update the EME setting 'Events page' accordingly.", 'events-made-easy' ), 'post_type' => 'page', 'post_status' => 'publish', 'comment_status' => 'closed', 'ping_status' => 'closed', - ); + ]; $int_post_id = wp_insert_post( $postarr ); if ( $int_post_id ) { update_option( 'eme_events_page', $int_post_id ); @@ -2082,7 +2082,7 @@ function eme_admin_footer_text( $text ) { $text = sprintf( /* translators: %s: review url */ __( 'If you like Events Made Easy, please leave a ★★★★★ rating. A huge thanks in advance!', 'events-made-easy' ), - 'https://wordpress.org/support/plugin/events-made-easy/reviews/?filter=5' + 'https://wordpress.org/support/plugin/events-made-easy/reviews/?filter=5' ); } return $text;