نحوه افزودن کدهای کوتاه سفارشی در Page Builder Sandwich

نوشته شده توسط

در

From the word itself, the word shortcode means exactly that: A short code; a shortcut code.

کدهای کوتاه (Shortcodes) به شما این امکان را می‌دهند که مواردی مانند ابزارک‌ها را بدون نیاز به افزودن قطعه‌کدهای بزرگ—کاری که توسعه‌دهندگان معمولاً انجام می‌دهند—به وب‌سایت خود اضافه کنید.

برای مثال، یک قطعه‌کد معمولی از نظر طول احتمالاً چیزی شبیه به این خواهد بود:

<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>​

برای این مثال، فرض کنیم که قطعه‌کد بالا به شما امکان می‌دهد یک پاراگراف کامل از متن ساختگی لورم ایپسوم را اضافه کنید.

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» است—دقیقاً همان کار را انجام دهند: افزودن متن لورم ایپسوم.

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)، تعریف به شرح زیر است:

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.

بخشی از این بدان معناست که دیگر نیازی نیست کدهای کوتاه خود را به صورت دستی در مستندات یا مخازن مربوط به آن‌ها جستجو کنید.

تا زمانی که افزونه حاوی کد کوتاه را روی سایت وردپرسی خود نصب داشته باشید، به راحتی برای استفاده در 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.

بنابراین اگر می‌خواهید کدهای کوتاه سفارشی یا کدهای کوتاهی را که خودتان ساخته‌اید اضافه کنید، تا زمانی که آن‌ها را روی سایت وردپرسی خود نصب کرده باشید، می‌توانید این کار را انجام دهید.

Here are some other helpful plugins that you can use to create your own custom shortcodes: