Is there any list of Magento compatible country codes? - magento
Looking for a country code list for calling or texting the countries specified in the Magento core.
I want to share how to get the country to phone code mapping with a Magento built-in function.
$countryPhoneMapping = Mage::app()
->getLocale()->getTranslationList('territorytophone');
var_dump($countryPhoneMapping); //something like array( 'AC' => 247, 'AD' => '376', ... )
Note: The data is fetched from the lib/Zend/Locale/Data/telephoneCodeData.xml file. Perhaps to mention the list will not contain any 4-digit phone codes. But for my approach it was enough.
In my case I had to show in a dropdown only the phone codes of selected countries in the Magento backend under System -> Configuration -> General -> Countries Options -> Allowed Countries
function country2phoneMapping() {
$options = array();
$allowedCountries = Mage::getModel('directory/country')
->getResourceCollection()
->loadByStore()
->toOptionArray();
$countryPhoneMapping = Mage::app()->getLocale()
->getTranslationList('territorytophone');
foreach( $allowedCountries as $value => $label ) { // e.g. DE => Germany
foreach( $countryPhoneMapping as $number => $territory ) { // e.g 49 => DE
if ( strpos( $territory, $value ) !== false ) {
$options[$value] = '+' . $number;
}
}
}
return $options;
}
Here's the full list of short name codes and the corresponding country code number. Listing in PHP array format so you should be able to do stuff with it in loops for formatting in any other way.
https://gist.github.com/bubach/9887414
Also inline (long):
$countryCodes = array(
array (
'country_code' => 'AF',
'phone_code' => '93',
),
array (
'country_code' => 'AX',
'phone_code' => '35818',
),
array (
'country_code' => 'NL',
'phone_code' => '31',
),
array (
'country_code' => 'AN',
'phone_code' => '599',
),
array (
'country_code' => 'AL',
'phone_code' => '355',
),
array (
'country_code' => 'DZ',
'phone_code' => '213',
),
array (
'country_code' => 'AS',
'phone_code' => '685',
),
array (
'country_code' => 'AD',
'phone_code' => '376',
),
array (
'country_code' => 'AO',
'phone_code' => '244',
),
array (
'country_code' => 'AI',
'phone_code' => '1264',
),
array (
'country_code' => 'AQ',
'phone_code' => '672',
),
array (
'country_code' => 'AG',
'phone_code' => '1268',
),
array (
'country_code' => 'AE',
'phone_code' => '971',
),
array (
'country_code' => 'AR',
'phone_code' => '54',
),
array (
'country_code' => 'AM',
'phone_code' => '374',
),
array (
'country_code' => 'AW',
'phone_code' => '297',
),
array (
'country_code' => 'AU',
'phone_code' => '61',
),
array (
'country_code' => 'AZ',
'phone_code' => '994',
),
array (
'country_code' => 'BS',
'phone_code' => '1242',
),
array (
'country_code' => 'BH',
'phone_code' => '973',
),
array (
'country_code' => 'BD',
'phone_code' => '880',
),
array (
'country_code' => 'BB',
'phone_code' => '1242',
),
array (
'country_code' => 'BE',
'phone_code' => '32',
),
array (
'country_code' => 'BZ',
'phone_code' => '501',
),
array (
'country_code' => 'BJ',
'phone_code' => '229',
),
array (
'country_code' => 'BM',
'phone_code' => '1441',
),
array (
'country_code' => 'BT',
'phone_code' => '975',
),
array (
'country_code' => 'BO',
'phone_code' => '591',
),
array (
'country_code' => 'BA',
'phone_code' => '387',
),
array (
'country_code' => 'BW',
'phone_code' => '267',
),
array (
'country_code' => 'BV',
'phone_code' => '47',
),
array (
'country_code' => 'BR',
'phone_code' => '55',
),
array (
'country_code' => 'GB',
'phone_code' => '44',
),
array (
'country_code' => 'IO',
'phone_code' => '246',
),
array (
'country_code' => 'VG',
'phone_code' => '1284',
),
array (
'country_code' => 'BN',
'phone_code' => '673',
),
array (
'country_code' => 'BG',
'phone_code' => '359',
),
array (
'country_code' => 'BF',
'phone_code' => '226',
),
array (
'country_code' => 'BI',
'phone_code' => '257',
),
array (
'country_code' => 'KY',
'phone_code' => '1345',
),
array (
'country_code' => 'CL',
'phone_code' => '56',
),
array (
'country_code' => 'CK',
'phone_code' => '682',
),
array (
'country_code' => 'CR',
'phone_code' => '506',
),
array (
'country_code' => 'DJ',
'phone_code' => '253',
),
array (
'country_code' => 'DM',
'phone_code' => '1767',
),
array (
'country_code' => 'DO',
'phone_code' => '1809',
),
array (
'country_code' => 'EC',
'phone_code' => '593',
),
array (
'country_code' => 'EG',
'phone_code' => '20',
),
array (
'country_code' => 'SV',
'phone_code' => '503',
),
array (
'country_code' => 'ER',
'phone_code' => '291',
),
array (
'country_code' => 'ES',
'phone_code' => '34',
),
array (
'country_code' => 'ZA',
'phone_code' => '27',
),
array (
'country_code' => 'GS',
'phone_code' => '500',
),
array (
'country_code' => 'KR',
'phone_code' => '82',
),
array (
'country_code' => 'ET',
'phone_code' => '251',
),
array (
'country_code' => 'FK',
'phone_code' => '500',
),
array (
'country_code' => 'FJ',
'phone_code' => '679',
),
array (
'country_code' => 'PH',
'phone_code' => '63',
),
array (
'country_code' => 'FO',
'phone_code' => '298',
),
array (
'country_code' => 'GA',
'phone_code' => '241',
),
array (
'country_code' => 'GM',
'phone_code' => '220',
),
array (
'country_code' => 'GE',
'phone_code' => '995',
),
array (
'country_code' => 'GH',
'phone_code' => '233',
),
array (
'country_code' => 'GI',
'phone_code' => '350',
),
array (
'country_code' => 'GD',
'phone_code' => '1473',
),
array (
'country_code' => 'GL',
'phone_code' => '299',
),
array (
'country_code' => 'GP',
'phone_code' => '590',
),
array (
'country_code' => 'GU',
'phone_code' => '1671',
),
array (
'country_code' => 'GT',
'phone_code' => '502',
),
array (
'country_code' => 'GG',
'phone_code' => '44',
),
array (
'country_code' => 'GN',
'phone_code' => '224',
),
array (
'country_code' => 'GW',
'phone_code' => '245',
),
array (
'country_code' => 'GY',
'phone_code' => '592',
),
array (
'country_code' => 'HT',
'phone_code' => '509',
),
array (
'country_code' => 'HM',
'phone_code' => '61',
),
array (
'country_code' => 'HN',
'phone_code' => '504',
),
array (
'country_code' => 'HK',
'phone_code' => '852',
),
array (
'country_code' => 'SJ',
'phone_code' => '47',
),
array (
'country_code' => 'ID',
'phone_code' => '62',
),
array (
'country_code' => 'IN',
'phone_code' => '91',
),
array (
'country_code' => 'IQ',
'phone_code' => '964',
),
array (
'country_code' => 'IR',
'phone_code' => '98',
),
array (
'country_code' => 'IE',
'phone_code' => '353',
),
array (
'country_code' => 'IS',
'phone_code' => '354',
),
array (
'country_code' => 'IL',
'phone_code' => '972',
),
array (
'country_code' => 'IT',
'phone_code' => '39',
),
array (
'country_code' => 'TL',
'phone_code' => '670',
),
array (
'country_code' => 'AT',
'phone_code' => '43',
),
array (
'country_code' => 'JM',
'phone_code' => '1876',
),
array (
'country_code' => 'JP',
'phone_code' => '81',
),
array (
'country_code' => 'YE',
'phone_code' => '967',
),
array (
'country_code' => 'JE',
'phone_code' => '44',
),
array (
'country_code' => 'JO',
'phone_code' => '962',
),
array (
'country_code' => 'CX',
'phone_code' => '61',
),
array (
'country_code' => 'KH',
'phone_code' => '855',
),
array (
'country_code' => 'CM',
'phone_code' => '237',
),
array (
'country_code' => 'CA',
'phone_code' => '1',
),
array (
'country_code' => 'CV',
'phone_code' => '238',
),
array (
'country_code' => 'KZ',
'phone_code' => '7',
),
array (
'country_code' => 'KE',
'phone_code' => '254',
),
array (
'country_code' => 'CF',
'phone_code' => '236',
),
array (
'country_code' => 'CN',
'phone_code' => '86',
),
array (
'country_code' => 'KG',
'phone_code' => '996',
),
array (
'country_code' => 'KI',
'phone_code' => '686',
),
array (
'country_code' => 'CO',
'phone_code' => '57',
),
array (
'country_code' => 'KM',
'phone_code' => '269',
),
array (
'country_code' => 'CG',
'phone_code' => '242',
),
array (
'country_code' => 'CD',
'phone_code' => '243',
),
array (
'country_code' => 'CC',
'phone_code' => '61',
),
array (
'country_code' => 'GR',
'phone_code' => '30',
),
array (
'country_code' => 'HR',
'phone_code' => '385',
),
array (
'country_code' => 'CU',
'phone_code' => '53',
),
array (
'country_code' => 'KW',
'phone_code' => '965',
),
array (
'country_code' => 'CY',
'phone_code' => '357',
),
array (
'country_code' => 'LA',
'phone_code' => '856',
),
array (
'country_code' => 'LV',
'phone_code' => '371',
),
array (
'country_code' => 'LS',
'phone_code' => '266',
),
array (
'country_code' => 'LB',
'phone_code' => '961',
),
array (
'country_code' => 'LR',
'phone_code' => '231',
),
array (
'country_code' => 'LY',
'phone_code' => '218',
),
array (
'country_code' => 'LI',
'phone_code' => '423',
),
array (
'country_code' => 'LT',
'phone_code' => '370',
),
array (
'country_code' => 'LU',
'phone_code' => '352',
),
array (
'country_code' => 'EH',
'phone_code' => '21228',
),
array (
'country_code' => 'MO',
'phone_code' => '853',
),
array (
'country_code' => 'MG',
'phone_code' => '261',
),
array (
'country_code' => 'MK',
'phone_code' => '389',
),
array (
'country_code' => 'MW',
'phone_code' => '265',
),
array (
'country_code' => 'MV',
'phone_code' => '960',
),
array (
'country_code' => 'MY',
'phone_code' => '60',
),
array (
'country_code' => 'ML',
'phone_code' => '223',
),
array (
'country_code' => 'MT',
'phone_code' => '356',
),
array (
'country_code' => 'IM',
'phone_code' => '44',
),
array (
'country_code' => 'MA',
'phone_code' => '212',
),
array (
'country_code' => 'MH',
'phone_code' => '692',
),
array (
'country_code' => 'MQ',
'phone_code' => '596',
),
array (
'country_code' => 'MR',
'phone_code' => '222',
),
array (
'country_code' => 'MU',
'phone_code' => '230',
),
array (
'country_code' => 'YT',
'phone_code' => '262',
),
array (
'country_code' => 'MX',
'phone_code' => '52',
),
array (
'country_code' => 'FM',
'phone_code' => '691',
),
array (
'country_code' => 'MD',
'phone_code' => '373',
),
array (
'country_code' => 'MC',
'phone_code' => '377',
),
array (
'country_code' => 'MN',
'phone_code' => '976',
),
array (
'country_code' => 'ME',
'phone_code' => '382',
),
array (
'country_code' => 'MS',
'phone_code' => '1664',
),
array (
'country_code' => 'MZ',
'phone_code' => '258',
),
array (
'country_code' => 'MM',
'phone_code' => '95',
),
array (
'country_code' => 'NA',
'phone_code' => '264',
),
array (
'country_code' => 'NR',
'phone_code' => '674',
),
array (
'country_code' => 'NP',
'phone_code' => '977',
),
array (
'country_code' => 'NI',
'phone_code' => '505',
),
array (
'country_code' => 'NE',
'phone_code' => '227',
),
array (
'country_code' => 'NG',
'phone_code' => '234',
),
array (
'country_code' => 'NU',
'phone_code' => '683',
),
array (
'country_code' => 'NF',
'phone_code' => '672',
),
array (
'country_code' => 'NO',
'phone_code' => '47',
),
array (
'country_code' => 'CI',
'phone_code' => '255',
),
array (
'country_code' => 'OM',
'phone_code' => '968',
),
array (
'country_code' => 'PK',
'phone_code' => '92',
),
array (
'country_code' => 'PW',
'phone_code' => '680',
),
array (
'country_code' => 'PS',
'phone_code' => '970',
),
array (
'country_code' => 'PA',
'phone_code' => '507',
),
array (
'country_code' => 'PG',
'phone_code' => '675',
),
array (
'country_code' => 'PY',
'phone_code' => '595',
),
array (
'country_code' => 'PE',
'phone_code' => '51',
),
array (
'country_code' => 'PN',
'phone_code' => '870',
),
array (
'country_code' => 'KP',
'phone_code' => '850',
),
array (
'country_code' => 'MP',
'phone_code' => '1670',
),
array (
'country_code' => 'PT',
'phone_code' => '351',
),
array (
'country_code' => 'PR',
'phone_code' => '1',
),
array (
'country_code' => 'PL',
'phone_code' => '48',
),
array (
'country_code' => 'GQ',
'phone_code' => '240',
),
array (
'country_code' => 'QA',
'phone_code' => '974',
),
array (
'country_code' => 'FR',
'phone_code' => '33',
),
array (
'country_code' => 'GF',
'phone_code' => '594',
),
array (
'country_code' => 'PF',
'phone_code' => '689',
),
array (
'country_code' => 'TF',
'phone_code' => '33',
),
array (
'country_code' => 'RO',
'phone_code' => '40',
),
array (
'country_code' => 'RW',
'phone_code' => '250',
),
array (
'country_code' => 'SE',
'phone_code' => '46',
),
array (
'country_code' => 'RE',
'phone_code' => '262',
),
array (
'country_code' => 'SH',
'phone_code' => '290',
),
array (
'country_code' => 'KN',
'phone_code' => '1869',
),
array (
'country_code' => 'LC',
'phone_code' => '1758',
),
array (
'country_code' => 'VC',
'phone_code' => '1784',
),
array (
'country_code' => 'BL',
'phone_code' => '590',
),
array (
'country_code' => 'MF',
'phone_code' => '1599',
),
array (
'country_code' => 'PM',
'phone_code' => '508',
),
array (
'country_code' => 'DE',
'phone_code' => '49',
),
array (
'country_code' => 'SB',
'phone_code' => '677',
),
array (
'country_code' => 'ZM',
'phone_code' => '260',
),
array (
'country_code' => 'WS',
'phone_code' => '685',
),
array (
'country_code' => 'SM',
'phone_code' => '378',
),
array (
'country_code' => 'SA',
'phone_code' => '966',
),
array (
'country_code' => 'SN',
'phone_code' => '221',
),
array (
'country_code' => 'RS',
'phone_code' => '381',
),
array (
'country_code' => 'SC',
'phone_code' => '248',
),
array (
'country_code' => 'SL',
'phone_code' => '232',
),
array (
'country_code' => 'SG',
'phone_code' => '65',
),
array (
'country_code' => 'SK',
'phone_code' => '421',
),
array (
'country_code' => 'SI',
'phone_code' => '386',
),
array (
'country_code' => 'SO',
'phone_code' => '252',
),
array (
'country_code' => 'LK',
'phone_code' => '94',
),
array (
'country_code' => 'SD',
'phone_code' => '249',
),
array (
'country_code' => 'FI',
'phone_code' => '358',
),
array (
'country_code' => 'SR',
'phone_code' => '594',
),
array (
'country_code' => 'CH',
'phone_code' => '41',
),
array (
'country_code' => 'SZ',
'phone_code' => '268',
),
array (
'country_code' => 'SY',
'phone_code' => '963',
),
array (
'country_code' => 'ST',
'phone_code' => '239',
),
array (
'country_code' => 'TJ',
'phone_code' => '992',
),
array (
'country_code' => 'TW',
'phone_code' => '886',
),
array (
'country_code' => 'TZ',
'phone_code' => '255',
),
array (
'country_code' => 'DK',
'phone_code' => '45',
),
array (
'country_code' => 'TH',
'phone_code' => '66',
),
array (
'country_code' => 'TG',
'phone_code' => '228',
),
array (
'country_code' => 'TK',
'phone_code' => '690',
),
array (
'country_code' => 'TO',
'phone_code' => '676',
),
array (
'country_code' => 'TT',
'phone_code' => '1868',
),
array (
'country_code' => 'TN',
'phone_code' => '216',
),
array (
'country_code' => 'TR',
'phone_code' => '90',
),
array (
'country_code' => 'TM',
'phone_code' => '993',
),
array (
'country_code' => 'TC',
'phone_code' => '1649',
),
array (
'country_code' => 'TV',
'phone_code' => '688',
),
array (
'country_code' => 'TD',
'phone_code' => '235',
),
array (
'country_code' => 'CZ',
'phone_code' => '420',
),
array (
'country_code' => 'UG',
'phone_code' => '256',
),
array (
'country_code' => 'UA',
'phone_code' => '380',
),
array (
'country_code' => 'HU',
'phone_code' => '36',
),
array (
'country_code' => 'UY',
'phone_code' => '598',
),
array (
'country_code' => 'NC',
'phone_code' => '687',
),
array (
'country_code' => 'NZ',
'phone_code' => '64',
),
array (
'country_code' => 'UZ',
'phone_code' => '998',
),
array (
'country_code' => 'BY',
'phone_code' => '375',
),
array (
'country_code' => 'VU',
'phone_code' => '678',
),
array (
'country_code' => 'VA',
'phone_code' => '39',
),
array (
'country_code' => 'VE',
'phone_code' => '58',
),
array (
'country_code' => 'RU',
'phone_code' => '7',
),
array (
'country_code' => 'VN',
'phone_code' => '84',
),
array (
'country_code' => 'EE',
'phone_code' => '372',
),
array (
'country_code' => 'WF',
'phone_code' => '681',
),
array (
'country_code' => 'US',
'phone_code' => '1',
),
array (
'country_code' => 'VI',
'phone_code' => '1340',
),
array (
'country_code' => 'UM',
'phone_code' => '1',
),
array (
'country_code' => 'ZW',
'phone_code' => '263',
)
);
you can get country list using directory modules
here the code below
Mage::getResourceModel('directory/country_collection')
->load()->toOptionArray();
Related
TYPO3 9.5 URL Routes
I have an old real_url.conf (from RealURL TYPO3 7.6). Now I have updated the system to TYPO3 9.5 and I need again the speaking URLs for my extension. Unfortunately, I don't have that yet, that's why I ask for advice here. 'postVarSets' => array( '_DEFAULT' => array ( "in" => array( array( 'GETvar' => 'pm_zahnarztprofiles[ort]' ), array( 'GETvar' => 'pm_zahnarztprofiles[stadtteil]' ), array( 'GETvar' => 'pm_zahnarztprofiles[name]' ), array( 'GETvar' => 'pm_zahnarztprofiles[id]' ), ), "page" => array( array( 'GETvar' => 'pm_zahnarztprofiles[page]' ) ), "sitemap" => array( array( 'GETvar' => 'pm_zahnarztprofiles[sitemap]' ) ), "html_sitemap" => array( array( 'GETvar' => 'pm_zahnarztprofiles[html_sitemap]' ) ), "search" => array( array( 'GETvar' => 'pm_zahnarztprofiles[search]' ), array( 'GETvar' => 'pm_zahnarztprofiles[page]' ) ) ) )
Speaking URL, Exclude from speaking URL does not funktion
(Tested with TYPO3 7.6 and RealURL 2.0.14 and 2.1.5) My Tree: +- [201] "General elements" (folder) +- [202] "Page 1" +- [203] "Page 2" +- [204] "Page 3" I have tried to exclude the folder General elements in this URL .../General elements/page1/page2/page3/ In the backend I have Enabled Page/General/Exclude from speaking URL and emptied the URL Cache and BE cache and everything but the folder won't disappear. my realurl_conf.php is this: 'fixedPostVars' => array( 'ReturnDetail' => array( array( 'GETvar' => 'tx_topitannoncen_annoncenlisting[annonceType]', 'valueMap' => array( 'projekte' => 0, 'stellen' => 1, 'intern' => 2 ), 'noMatch' => 'bypass', ), ), '148' => 'ReturnDetail', '202' => 'ReturnDetail', 'newsDetailConfiguration' => array( array( 'GETvar' => 'tx_topitannoncen_annoncenlisting[action]', 'valueMap' => array( ), 'noMatch' => 'bypass' ), array( 'GETvar' => 'tx_topitannoncen_annoncenlisting[controller]', 'valueMap' => array( ), 'noMatch' => 'bypass' ), array( 'GETvar' => 'tx_topitannoncen_annoncenlisting[returnAction]', 'valueMap' => array( ), 'noMatch' => 'bypass' ), array( 'GETvar' => 'tx_topitannoncen_annoncenlisting[returnId]', 'valueMap' => array( ), 'noMatch' => 'bypass' ), array( 'GETvar' => 'tx_topitannoncen_annoncenlisting[annonce]', 'lookUpTable' => array( 'table' => 'tx_topitannoncen_domain_model_annonce', 'id_field' => 'uid', 'alias_field' => "concat(advert_title,'-',advert_number)", 'addWhereClause' => ' AND NOT deleted', 'useUniqueCache' => 1, 'useUniqueCache_conf' => array( 'strtolower' => 1, 'spaceCharacter' => '_', ), ), ), ), '173' => 'newsDetailConfiguration', '204' => 'newsDetailConfiguration', 148 and 202 are the Folders which should be hide in the url but what I get is http://www.~/General-elements/Page1/Page2/Page3/engin-mw-667-9178/ I want it like this http://www.~/Page1/Page2/detail/engin-mw-667-9178/
How to Make a Status Field Bydefault Enable in Magento Form?
Following is my Form Field Code. $fieldset->addField('status','select', array( 'label' => Mage::helper('synclogin')->__('Eshot Status'), 'name' => 'status', 'values' => array( array( 'value' => 0, 'label' => Mage::helper('synclogin')->__('Disabled'), ), array( 'value' => 1, 'label' => Mage::helper('synclogin')->__('Enabled'), ), ), ) ); How to Make a Status Field Bydefault Enable in Magento Form?
$fieldset->addField('status','select', array( 'label' => Mage::helper('synclogin')->__('Eshot Status'), 'name' => 'status', 'value' => '1', 'values' => array( array( 'value' => 0, 'label' => Mage::helper('synclogin')->__('Disabled'), ), array( 'value' => 1, 'label' => Mage::helper('synclogin')->__('Enabled'), ), ), ) );
Divi image gallery sorting
Hope someone could help me with this one! I've already asked for their support but "it goes beyond their support level" and they even adviced me to ask it here.. So I'm using the Divi image gallery for my wordpress catalog, which contains lots of images. Now I'm looking for a way that the images in the gallery are standard sorted by filename. Any guidelines how to do change this in their code? Thanks a lot!!
File names for attachments are stored in the 'post_name' column of the posts table. Therefore, this simple change should do the trick. The simple answer to your question is: Locate the file divi/includes/builder/main-modules.php Search for function get_galleryin the file From there, scroll down slightly to find $attachments_args Change 'orderby' => 'post__in' to 'orderby' => 'post_name' The bad news... Making a change to main-modules.php means either you can no longer do updates or when you do update you'll have to apply the hack again.
Michael is right BUT: The good news You you can insert it into your Child Theme and everything is save The better answer to your question is: Locate the file divi/includes/builder/main-modules.php Copy the ET_Builder_Module_Gallery Insert into your functions.php, wrap and modify like Michael said Complete code for this function divi_child_theme_setup() { if ( class_exists('ET_Builder_Module')) { class CHILD_ET_Builder_Module_Gallery extends ET_Builder_Module { function init() { $this->name = esc_html__( 'Gallery', 'et_builder' ); $this->slug = 'et_pb_gallery'; $this->fb_support = true; $this->whitelisted_fields = array( 'src', 'gallery_ids', 'gallery_orderby', 'fullwidth', 'posts_number', 'show_title_and_caption', 'show_pagination', 'background_layout', 'auto', 'auto_speed', 'admin_label', 'module_id', 'module_class', 'zoom_icon_color', 'hover_overlay_color', 'hover_icon', 'orientation', ); $this->fields_defaults = array( 'fullwidth' => array( 'off' ), 'posts_number' => array( 4, 'add_default_setting' ), 'show_title_and_caption' => array( 'on' ), 'show_pagination' => array( 'on' ), 'background_layout' => array( 'light' ), 'auto' => array( 'off' ), 'auto_speed' => array( '7000' ), 'orientation' => array( 'landscape' ), ); $this->options_toggles = array( 'general' => array( 'toggles' => array( 'main_content' => esc_html__( 'Images', 'et_builder' ), 'elements' => esc_html__( 'Elements', 'et_builder' ), ), ), 'advanced' => array( 'toggles' => array( 'layout' => esc_html__( 'Layout', 'et_builder' ), 'overlay' => esc_html__( 'Overlay', 'et_builder' ), 'text' => array( 'title' => esc_html__( 'Text', 'et_builder' ), 'priority' => 49, ), ), ), 'custom_css' => array( 'toggles' => array( 'animation' => array( 'title' => esc_html__( 'Animation', 'et_builder' ), 'priority' => 90, ), ), ), ); $this->main_css_element = '%%order_class%%.et_pb_gallery'; $this->advanced_options = array( 'fonts' => array( 'title' => array( 'label' => esc_html__( 'Title', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .et_pb_gallery_title", ), ), 'caption' => array( 'label' => esc_html__( 'Caption', 'et_builder' ), 'use_all_caps' => true, 'css' => array( 'main' => "{$this->main_css_element} .mfp-title, {$this->main_css_element} .et_pb_gallery_caption", ), 'line_height' => array( 'range_settings' => array( 'min' => '1', 'max' => '100', 'step' => '1', ), ), 'depends_show_if' => 'off' ), ), 'border' => array( 'css' => array( 'main' => "{$this->main_css_element} .et_pb_gallery_item", ), ), ); $this->custom_css_options = array( 'gallery_item' => array( 'label' => esc_html__( 'Gallery Item', 'et_builder' ), 'selector' => '.et_pb_gallery_item', ), 'overlay' => array( 'label' => esc_html__( 'Overlay', 'et_builder' ), 'selector' => '.et_overlay', ), 'overlay_icon' => array( 'label' => esc_html__( 'Overlay Icon', 'et_builder' ), 'selector' => '.et_overlay:before', ), 'gallery_item_title' => array( 'label' => esc_html__( 'Gallery Item Title', 'et_builder' ), 'selector' => '.et_pb_gallery_title', ), 'gallery_item_caption' => array( 'label' => esc_html__( 'Gallery Item Caption', 'et_builder' ), 'selector' => '.et_pb_gallery_caption', ), 'gallery_pagination' => array( 'label' => esc_html__( 'Gallery Pagination', 'et_builder' ), 'selector' => '.et_pb_gallery_pagination', ), 'gallery_pagination_active' => array( 'label' => esc_html__( 'Pagination Active Page', 'et_builder' ), 'selector' => '.et_pb_gallery_pagination a.active', ), ); } function get_fields() { $fields = array( 'src' => array( 'label' => esc_html__( 'Gallery Images', 'et_builder' ), 'renderer' => 'et_builder_get_gallery_settings', 'option_category' => 'basic_option', 'overwrite' => array( 'ids' => 'gallery_ids', 'orderby' => 'gallery_orderby', ), 'toggle_slug' => 'main_content', ), 'gallery_ids' => array( 'type' => 'hidden', 'class' => array( 'et-pb-gallery-ids-field' ), 'computed_affects' => array( '__gallery', ), ), 'gallery_orderby' => array( 'label' => esc_html__( 'Gallery Images', 'et_builder' ), 'type' => 'hidden', 'class' => array( 'et-pb-gallery-ids-field' ), 'computed_affects' => array( '__gallery', ), 'toggle_slug' => 'main_content', ), 'fullwidth' => array( 'label' => esc_html__( 'Layout', 'et_builder' ), 'type' => 'select', 'option_category' => 'layout', 'options' => array( 'off' => esc_html__( 'Grid', 'et_builder' ), 'on' => esc_html__( 'Slider', 'et_builder' ), ), 'description' => esc_html__( 'Toggle between the various blog layout types.', 'et_builder' ), 'affects' => array( 'zoom_icon_color', 'caption_font', 'caption_text_color', 'caption_line_height', 'caption_font_size', 'caption_all_caps', 'caption_letter_spacing', 'hover_overlay_color', 'auto', 'posts_number', 'show_title_and_caption', 'orientation' ), 'computed_affects' => array( '__gallery', ), 'tab_slug' => 'advanced', 'toggle_slug' => 'layout', ), 'posts_number' => array( 'label' => esc_html__( 'Images Number', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'description' => esc_html__( 'Define the number of images that should be displayed per page.', 'et_builder' ), 'depends_show_if' => 'off', 'toggle_slug' => 'main_content', ), 'orientation' => array( 'label' => esc_html__( 'Thumbnail Orientation', 'et_builder' ), 'type' => 'select', 'options_category' => 'configuration', 'options' => array( 'landscape' => esc_html__( 'Landscape', 'et_builder' ), 'portrait' => esc_html__( 'Portrait', 'et_builder' ) ), 'description' => sprintf( '%1$s<br><small><em><strong>%2$s:</strong> %3$s %4$s.</em></small>', esc_html__( 'Choose the orientation of the gallery thumbnails.', 'et_builder' ), esc_html__( 'Note', 'et_builder' ), esc_html__( 'If this option appears to have no effect, you might need to', 'et_builder' ), esc_html__( 'regenerate your thumbnails', 'et_builder') ), 'depends_show_if' => 'off', 'computed_affects' => array( '__gallery', ), 'tab_slug' => 'advanced', 'toggle_slug' => 'layout', ), 'show_title_and_caption' => array( 'label' => esc_html__( 'Show Title and Caption', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'configuration', 'options' => array( 'on' => esc_html__( 'Yes', 'et_builder' ), 'off' => esc_html__( 'No', 'et_builder' ), ), 'description' => esc_html__( 'Whether or not to show the title and caption for images (if available).', 'et_builder' ), 'depends_show_if' => 'off', 'toggle_slug' => 'elements', ), 'show_pagination' => array( 'label' => esc_html__( 'Show Pagination', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'configuration', 'options' => array( 'on' => esc_html__( 'Yes', 'et_builder' ), 'off' => esc_html__( 'No', 'et_builder' ), ), 'toggle_slug' => 'elements', 'description' => esc_html__( 'Enable or disable pagination for this feed.', 'et_builder' ), ), 'background_layout' => array( 'label' => esc_html__( 'Text Color', 'et_builder' ), 'type' => 'select', 'option_category' => 'color_option', 'options' => array( 'light' => esc_html__( 'Dark', 'et_builder' ), 'dark' => esc_html__( 'Light', 'et_builder' ), ), 'tab_slug' => 'advanced', 'toggle_slug' => 'text', 'description' => esc_html__( 'Here you can choose whether your text should be light or dark. If you are working with a dark background, then your text should be light. If your background is light, then your text should be set to dark.', 'et_builder' ), ), 'auto' => array( 'label' => esc_html__( 'Automatic Animation', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'configuration', 'options' => array( 'off' => esc_html__( 'Off', 'et_builder' ), 'on' => esc_html__( 'On', 'et_builder' ), ), 'affects' => array( 'auto_speed', ), 'depends_show_if' => 'on', 'depends_to' => array( 'fullwidth', ), 'tab_slug' => 'custom_css', 'toggle_slug' => 'animation', 'description' => esc_html__( 'If you would like the slider to slide automatically, without the visitor having to click the next button, enable this option and then adjust the rotation speed below if desired.', 'et_builder' ), ), 'auto_speed' => array( 'label' => esc_html__( 'Automatic Animation Speed (in ms)', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'depends_default' => true, 'tab_slug' => 'custom_css', 'toggle_slug' => 'animation', 'description' => esc_html__( "Here you can designate how fast the slider fades between each slide, if 'Automatic Animation' option is enabled above. The higher the number the longer the pause between each rotation.", 'et_builder' ), ), 'zoom_icon_color' => array( 'label' => esc_html__( 'Zoom Icon Color', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'depends_show_if' => 'off', 'tab_slug' => 'advanced', 'toggle_slug' => 'overlay', ), 'hover_overlay_color' => array( 'label' => esc_html__( 'Hover Overlay Color', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'depends_show_if' => 'off', 'tab_slug' => 'advanced', 'toggle_slug' => 'overlay', ), 'hover_icon' => array( 'label' => esc_html__( 'Hover Icon Picker', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'class' => array( 'et-pb-font-icon' ), 'renderer' => 'et_pb_get_font_icon_list', 'renderer_with_field' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'overlay', ), 'disabled_on' => array( 'label' => esc_html__( 'Disable on', 'et_builder' ), 'type' => 'multiple_checkboxes', 'options' => array( 'phone' => esc_html__( 'Phone', 'et_builder' ), 'tablet' => esc_html__( 'Tablet', 'et_builder' ), 'desktop' => esc_html__( 'Desktop', 'et_builder' ), ), 'additional_att' => 'disable_on', 'option_category' => 'configuration', 'description' => esc_html__( 'This will disable the module on selected devices', 'et_builder' ), 'tab_slug' => 'custom_css', 'toggle_slug' => 'visibility', ), 'admin_label' => array( 'label' => esc_html__( 'Admin Label', 'et_builder' ), 'type' => 'text', 'description' => esc_html__( 'This will change the label of the module in the builder for easy identification.', 'et_builder' ), 'toggle_slug' => 'admin_label', ), 'module_id' => array( 'label' => esc_html__( 'CSS ID', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'tab_slug' => 'custom_css', 'toggle_slug' => 'classes', 'option_class' => 'et_pb_custom_css_regular', ), 'module_class' => array( 'label' => esc_html__( 'CSS Class', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'tab_slug' => 'custom_css', 'toggle_slug' => 'classes', 'option_class' => 'et_pb_custom_css_regular', ), '__gallery' => array( 'type' => 'computed', 'computed_callback' => array( 'ET_Builder_Module_Gallery', 'get_gallery' ), 'computed_depends_on' => array( 'gallery_ids', 'gallery_orderby', 'fullwidth', 'orientation', ), ), ); return $fields; } /** * Get attachment data for gallery module * * #param array $args { * Gallery Options * * #type array $gallery_ids Attachment Ids of images to be included in gallery. * #type string $gallery_orderby `orderby` arg for query. Optional. * #type string $fullwidth on|off to determine grid / slider layout * #type string $orientation Orientation of thumbnails (landscape|portrait). * } * #param array $conditional_tags * #param array $current_page * * #return array Attachments data */ static function get_gallery( $args = array(), $conditional_tags = array(), $current_page = array() ) { $attachments = array(); $defaults = array( 'gallery_ids' => array(), 'gallery_orderby' => '', 'fullwidth' => 'off', 'orientation' => 'landscape', ); $args = wp_parse_args( $args, $defaults ); $attachments_args = array( 'include' => $args['gallery_ids'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'post_name', ); if ( 'rand' === $args['gallery_orderby'] ) { $attachments_args['orderby'] = 'rand'; } if ( 'on' === $args['fullwidth'] ) { $width = 1080; $height = 9999; } else { $width = 400; $height = ( 'landscape' === $args['orientation'] ) ? 284 : 516; } $width = (int) apply_filters( 'et_pb_gallery_image_width', $width ); $height = (int) apply_filters( 'et_pb_gallery_image_height', $height ); $_attachments = get_posts( $attachments_args ); foreach ( $_attachments as $key => $val ) { $attachments[$key] = $_attachments[$key]; $attachments[$key]->image_src_full = wp_get_attachment_image_src( $val->ID, 'full' ); $attachments[$key]->image_src_thumb = wp_get_attachment_image_src( $val->ID, array( $width, $height ) ); } return $attachments; } function shortcode_callback( $atts, $content = null, $function_name ) { $module_id = $this->shortcode_atts['module_id']; $module_class = $this->shortcode_atts['module_class']; $gallery_ids = $this->shortcode_atts['gallery_ids']; $fullwidth = $this->shortcode_atts['fullwidth']; $show_title_and_caption = $this->shortcode_atts['show_title_and_caption']; $background_layout = $this->shortcode_atts['background_layout']; $posts_number = $this->shortcode_atts['posts_number']; $show_pagination = $this->shortcode_atts['show_pagination']; $gallery_orderby = $this->shortcode_atts['gallery_orderby']; $zoom_icon_color = $this->shortcode_atts['zoom_icon_color']; $hover_overlay_color = $this->shortcode_atts['hover_overlay_color']; $hover_icon = $this->shortcode_atts['hover_icon']; $auto = $this->shortcode_atts['auto']; $auto_speed = $this->shortcode_atts['auto_speed']; $orientation = $this->shortcode_atts['orientation']; $module_class = ET_Builder_Element::add_module_order_class( $module_class, $function_name ); if ( '' !== $zoom_icon_color ) { ET_Builder_Element::set_style( $function_name, array( 'selector' => '%%order_class%% .et_overlay:before', 'declaration' => sprintf( 'color: %1$s !important;', esc_html( $zoom_icon_color ) ), ) ); } if ( '' !== $hover_overlay_color ) { ET_Builder_Element::set_style( $function_name, array( 'selector' => '%%order_class%% .et_overlay', 'declaration' => sprintf( 'background-color: %1$s; border-color: %1$s;', esc_html( $hover_overlay_color ) ), ) ); } // Get gallery item data $attachments = self::get_gallery( array( 'gallery_ids' => $gallery_ids, 'gallery_orderby' => $gallery_orderby, 'fullwidth' => $fullwidth, 'orientation' => $orientation, ) ); if ( empty( $attachments ) ) { return ''; } wp_enqueue_script( 'hashchange' ); $fullwidth_class = 'on' === $fullwidth ? ' et_pb_slider et_pb_gallery_fullwidth' : ' et_pb_gallery_grid'; $background_class = " et_pb_bg_layout_{$background_layout}"; $module_class .= 'on' === $auto && 'on' === $fullwidth ? ' et_slider_auto et_slider_speed_' . esc_attr( $auto_speed ) : ''; $posts_number = 0 === intval( $posts_number ) ? 4 : intval( $posts_number ); $output = sprintf( '<div%1$s class="et_pb_module et_pb_gallery%2$s%3$s%4$s clearfix"> <div class="et_pb_gallery_items et_post_gallery" data-per_page="%5$d">', ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ), ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( ltrim( $module_class ) ) ) : '' ), esc_attr( $fullwidth_class ), esc_attr( $background_class ), esc_attr( $posts_number ) ); foreach ( $attachments as $id => $attachment ) { $data_icon = '' !== $hover_icon ? sprintf( ' data-icon="%1$s"', esc_attr( et_pb_process_font_icon( $hover_icon ) ) ) : ''; $image_output = sprintf( '<a href="%1$s" title="%2$s"> <img src="%3$s" alt="%2$s" /> <span class="et_overlay%4$s"%5$s></span> </a>', esc_url( $attachment->image_src_full[0] ), esc_attr( $attachment->post_title ), esc_url( $attachment->image_src_thumb[0] ), ( '' !== $hover_icon ? ' et_pb_inline_icon' : '' ), $data_icon ); $output .= sprintf( '<div class="et_pb_gallery_item%2$s%1$s">', esc_attr( $background_class ), ( 'on' !== $fullwidth ? ' et_pb_grid_item' : '' ) ); $output .= " <div class='et_pb_gallery_image {$orientation}'> $image_output </div>"; if ( 'on' !== $fullwidth && 'on' === $show_title_and_caption ) { if ( trim($attachment->post_title) ) { $output .= " <h3 class='et_pb_gallery_title'> " . wptexturize($attachment->post_title) . " </h3>"; } if ( trim($attachment->post_excerpt) ) { $output .= " <p class='et_pb_gallery_caption'> " . wptexturize($attachment->post_excerpt) . " </p>"; } } $output .= "</div>"; } $output .= "</div><!-- .et_pb_gallery_items -->"; if ( 'on' !== $fullwidth && 'on' === $show_pagination ) { $output .= "<div class='et_pb_gallery_pagination'></div>"; } $output .= "</div><!-- .et_pb_gallery -->"; return $output; } } $cgm = new CHILD_ET_Builder_Module_Gallery(); remove_shortcode( 'et_pb_gallery' ); add_shortcode( 'et_pb_gallery', array($cgm, '_shortcode_callback') ); } } add_action('wp', 'divi_child_theme_setup', 9999); I used code from Divi 3.0.51. have fun
orderby not working on wordpress
I trying to order by this values by a custom field (motor) and this is not working. Can you help me? I use acf to create the custom field. And when I do a var_dump it doesn't recognize the order by the parameter. $args=''; $args = array( 'post_type' => 'grupoelectrogeno', 'post_status' => 'publish', 'posts_per_page' => '100', 'meta_query' => array( array( 'key' => 'potencia_continua', 'value' => $postpotencia, 'compare' => 'like' ), array( 'key' => 'motor', 'value' => $postmotor, 'compare' => 'like' ), array( 'key' => 'version', 'value' => $postversion, 'compare' => 'like' ), array( 'key' => 'gama', 'value' => 'industrial', 'compare' => 'like' ), 'orderby' => 'motor', 'order'=>'desc', ), );