From the word itself, the word shortcode means exactly that: A short code; a shortcut code.
Шорткоды позволяют добавлять различные элементы на ваш сайт (например, виджеты) без необходимости вставлять огромные фрагменты кода, как это обычно делают разработчики.
Например, обычный фрагмент кода по своей длине выглядел бы примерно так:
<html>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam id aliquam turpis. Vivamus quis arcu tincidunt, finibus urna eget, placerat risus. Aliquam arcu massa, finibus et lacinia sed, scelerisque nec augue. Quisque eu viverra sapien, vel consequat lorem. Integer vel erat tortor. Phasellus condimentum magna eget congue venenatis. Suspendisse blandit vehicula consectetur. Nullam sodales eleifend massa, in bibendum purus fermentum id. Morbi et turpis feugiat, malesuada ipsum sit amet, interdum nulla. In non ante nec nisl mattis gravida sit amet id lectus. </html>
Для этого примера давайте представим, что приведенный выше фрагмент кода позволяет добавить целый абзац текста-рыбы Lorem Ipsum.
Now, a shortcode with the same exact function as the code above will look something like this, in contrast:
[lorem ipsum dolor estat]Lorem Ipsum[/lorem]
You can see how they’re miles different from each other in terms of length.
А теперь представьте, что оба фрагмента кода — исходный, длинный фрагмент и шорткод, содержащий только слово «lorem», — делают абсолютно одно и то же: добавляют текст Lorem Ipsum.
This is what shortcodes do. They make adding widgets, functions, and a bunch of other cool stuff easier for both ordinary WordPress users and developers alike.
Where can I find shortcodes?
Если у вас есть любимый плагин или виджет, велика вероятность, что для него предусмотрен готовый к использованию шорткод.
Shortcodes Ultimate, for example, will let you choose from hundreds of shortcodes that you can use on Page Builder Sandwich (or anywhere, actually) by simply grabbing the shortcode of your choice from Shortcode Ultimate’s repository or documentation page.
Adding Custom Shortcodes on PBS
В Page Builder Sandwich вы можете добавлять шорткоды прямо на страницу, просто введя или вставив их в область контента.
Ниже мы сделали это с помощью шорткода из Shortcodes Ultimate, добавив блок с контентом на демо-страницу Page Builder Sandwich:
Another thing you’ll find handy when using Page Builder Sandwich is our Shortcode Mapping feature.
В одной из наших предыдущих статей о маппинге шорткодов определение звучало следующим образом:
Shortcode mapping is like letting Page Builder Sandwich memorize all the shortcodes available on your site: their names, descriptions, their attributes, and what each of these attributes do.
Отчасти это означает, что вам больше не придется вручную искать нужные шорткоды в соответствующей документации или репозиториях.
Пока плагин, содержащий шорткод, установлен на вашем сайте WordPress, он будет легко доступен для использования в Page Builder Sandwich.
So for example, if I wanted to add a WooCommerce shortcode on my page, all I have to do is make sure that it’s installed on my WordPress site, like so:
And then, to actually add the shortcode, I’ll just go to my page, and drag and drop the Shortcode Element:
Because we already have WooCommerce installed on our WordPress site, you can see that all of the shortcodes that are available on the WooCommerce plugin are already available on Page Builder Sandwich. This is what Shortcode Mapping is.
You can also see on the upper left corner that the ACF (Advanced Custom Fields) and MailChimp shortcodes are available— because we have those instlled on our WordPress site, too.
Поэтому, если вы хотите добавить собственные шорткоды или шорткоды, созданные вами самостоятельно, вы можете сделать это при условии, что они установлены на вашем сайте WordPress.
