جستجو برای:
سبد خرید 0
  • صفحه اصلی
  • مقالات و آموزش ها
  • فروشگاه
  • درباره ما
  • پرسش و پاسخ
  • دانلود وردپرس
  • ارتباط با ما

ورود

رمز عبور را فراموش کرده اید؟

هنوز عضو نشده اید؟ عضویت در سایت
  • phone 04133252264
  • email info@wpnegar.ir
perm_identity
سبد خرید 0
  • قوانین و مقررات
  • ثبت تیکت
0
وردپرس نگار (وی‌پی نگار) - WP Negar
  • صفحه اصلی
  • مقالات و آموزش ها
  • فروشگاه
  • درباره ما
  • پرسش و پاسخ
  • دانلود وردپرس
  • ارتباط با ما
perm_identity ورود و ثبت نام

وبلاگ

وردپرس نگار (وی‌پی نگار) - WP Negar > مقالات و آموزش ها > آموزش وردپرس > توضیحاتی درباره وردپرس wp_head و پاک سازی آن

توضیحاتی درباره وردپرس wp_head و پاک سازی آن

access_time30 ژانویه 2017
perm_identity ارسال شده توسط پونه آذری
folder_open آموزش وردپرس, کد وردپرس
visibility 537 بازدید
head-wpNegar

با عرض سلام و روز خوش خدمت دوستان عزیز؛
امروز در این مقاله وردپرس به صورت مختصر توضیحاتی درباره وردپرس wp_head  برای شما می دهیم. همچنین در ادامه به عملیات پاک سازی وردپرس wp_head که در افزایش سرعت سایت موثر است، می پردازیم. پس با بهینه سازی این فایل می توانید در بهینه سازی کلی سایت قدمی بردارید!

وردپرس wp_head

wp_head یک عمل هوک(action hook)  در بخش <head></head> از قالب کاربر که با تابع () wp_head در تعامل است. اگرچه این مورد وابسته به پوسته است، اما این هوک یکی از ضروری ترین هوک های تم ها است که از آن به طور گسترده پشتیبانی می شود.

این تابع، یک بسته بندی ساده است برای:

&amp;lt;?php do_action('wp_head'); ?&amp;gt;

هوک ها پارامتری ندارند. شما می توانید از هوک ها با استفاده از توابع نوشتاری در مرورگر استفاده کنید، یا از آن ها در پس زمینه پلتفرم کارها استفاده نمایید. این توابع خروجی ندارند و هیچ پارامتری نمی گیرند.
هوک ها وابسته به قالب هستند. این بدان معنی است که نویسنده قالب انتخاب می کند که از آن ها استفاده کند یا خیر. ممکن است که در همه پوسته های وردپرس موجود نباشد. شما باید در صورتی که از آن استفاده می کنید وارد اکانت خود شوید.
این هوک عملی را انجام می دهد که برای ایجاد یک رویداد مهم و مورد نیاز است. البته به جای یک محتوا قرار داده شده است. این یک تفاوت معنایی است، اما به شما کمک می کند تا به یاد آورید این هوک چه کاری می کند. در صورتی که همانند نمونه زیر از آن استفاده نمایید:

<code class="php plain">&lt;?php add_action(</code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'your_function'</code><code class="php plain">); ?&gt;</code>

اقدامات (actions) پیش فرض

بسیاری از اقدامات (actions) به صورت پیش فرض شامل هوک، وردپرس wp-head می باشند، که به وسیله هسته وردپرس در wp-includes/default-filters.phpp راه اندازی شده است. اگر شما نیاز به حذف یک هوک پیش فرض دارید، این فایل به شما اولویت حذف هوک پیش فرض را می دهد.

حال به بررسی نمونه مثال هایی می پردازیم:

افزودن css سفارشی به قسمت head، با استفاده از action وردپرس wp_head:

</pre>
<div class="line number1 index0 alt2"><code class="php keyword">function</code> <code class="php plain">hook_css() {</code></div>
<div class="line number2 index1 alt1"><code class="php spaces">    </code><code class="php plain">?&gt;</code></div>
<div class="line number3 index2 alt2"><code class="php spaces">        </code></div>
<div class="line number4 index3 alt1"><code class="php plain">&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP</code><code class="php comments">///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cstyle%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20.wp_head_example%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20background-color%20%3A%20%23f1f1f1%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%3C%2Fstyle%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&amp;lt;style&amp;gt;&quot; title=&quot;&amp;lt;style&amp;gt;&quot; /&gt;</code></div>
<div class="line number5 index4 alt2"></div>
<div class="line number6 index5 alt1"><code class="php spaces">    </code><code class="php plain">&lt;?php</code></div>
<div class="line number7 index6 alt2"><code class="php plain">}</code></div>
<div class="line number8 index7 alt1"><code class="php plain">add_action(</code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'hook_css'</code><code class="php plain">);</code></div>
<pre>

افزودن جاوا اسکریپت سفارشی به قسمت head، با استفاده از action وردپرس wp_head:

</pre>
<div class="line number1 index0 alt2"><code class="php keyword">function</code> <code class="php plain">hook_javascript() {</code></div>
<div class="line number2 index1 alt1"><code class="php spaces">    </code><code class="php plain">?&gt;</code></div>
<div class="line number3 index2 alt2"><code class="php spaces">        </code><code class="php plain">&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP</code><code class="php comments">///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot; data-wp-preserve=&quot;%3Cscript%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20alert('Page%20is%20loading...')%3B%0A%20%20%20%20%20%20%20%20%3C%2Fscript%3E&quot; data-mce-resize=&quot;false&quot; data-mce-placeholder=&quot;1&quot; class=&quot;mce-object&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;&amp;lt;script&amp;gt;&quot; title=&quot;&amp;lt;script&amp;gt;&quot; /&gt;</code></div>
<div class="line number4 index3 alt1"><code class="php spaces">    </code><code class="php plain">&lt;?php</code></div>
<div class="line number5 index4 alt2"><code class="php plain">}</code></div>
<div class="line number6 index5 alt1"><code class="php plain">add_action(</code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'hook_javascript'</code><code class="php plain">);</code></div>
<pre>

توجه!! عمل هوک(action hook) وردپرس wp_head  در wp-includes/general-template.php  قرار گرفته است!

پاک سازی وردپرس wp-head

وردپرس به طور خودکار یک سری رشته های meta را از طریق وردپرس wp-head شما می افزاید. ما میخواهیم با یک سری توابع کوتاه wp_head را پاکسازی کنیم.
برای این کار کافیست توابع زیر را در functions.php خود قرار دهید :

</pre>
<div class="line number1 index0 alt2"><code class="php plain">remove_action( </code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'rsd_link'</code> <code class="php plain">);</code></div>
<div class="line number2 index1 alt1"><code class="php plain">remove_action( </code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'wlwmanifest_link'</code> <code class="php plain">);</code></div>
<div class="line number3 index2 alt2"><code class="php plain">remove_action( </code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'wp_generator'</code> <code class="php plain">);</code></div>
<div class="line number4 index3 alt1"><code class="php plain">remove_action( </code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'start_post_rel_link'</code> <code class="php plain">);</code></div>
<div class="line number5 index4 alt2"><code class="php plain">remove_action( </code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'index_rel_link'</code> <code class="php plain">);</code></div>
<div class="line number6 index5 alt1"><code class="php plain">remove_action( </code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'adjacent_posts_rel_link'</code> <code class="php plain">);</code></div>
<div class="line number7 index6 alt2"><code class="php plain">remove_action( </code><code class="php string">'wp_head'</code><code class="php plain">, </code><code class="php string">'wp_shortlink_wp_head'</code> <code class="php plain">);</code></div>
<pre>

نکته!!! فقط قبل هر عملی بک آپ از functions.php خود فراموش نشود !

برچسب ها: wp_head و پاک سازی آنبهبود سئو بدون پلاگینتمیز کردن header وردپرسکد وردپرسوردپرس wp_head
درباره پونه آذری

کارشناس ارشد معماری سیستم های کامپیوتری، برنامه نویس ویندوز

نوشته های بیشتر از پونه آذری
مطالب زیر را حتما بخوانید
  • فیلد تصاویر
    افزودن فیلد تصاویر به دسته‌ های وردپرس

    2.33k بازدید

  • Avoid CSS expressions
    خطای Avoid CSS expressions در gtmetrix

    1.91k بازدید

  • جی تی متریکس
    جی تی متریکس (GTmetrix) چیست؟

    1.99k بازدید

  • غیرفعال کردن حساسیت رمز عبور
    غیرفعال کردن حساسیت رمز عبور ووکامرس زمان خرید و ثبت نام

    2k بازدید

  • افزونه Comment Link Remove
    افزونه و کد حذف فیلد آدرس از بخش نظرات وردپرس

    2.1k بازدید

جدید تر ساخت انواع دکمه در وردپرس با MaxButtons
قدیمی تر ساخت پنجره پاپ آپ در وردپرس با Popup Maker

دیدگاهتان را بنویسید لغو پاسخ

جستجو برای:
محصولات
  • قالب استارتاپی و دیجیتال مارکتینگ هوپر | Hoper ۷۰,۰۰۰ تومان ۴۰,۰۰۰ تومان
  • ویژوال کامپوزر افزونه ویژوال کامپوزر - WP Bakery Visual Composer فارسی نسخه 5.6 ۴۰,۰۰۰ تومان ۳۲,۰۰۰ تومان
  • افزونه مقایسه محصولات ووکامرس افزونه مقایسه پیشرفته محصولات ووکامرس - افزونه قیاس ۳۵,۰۰۰ تومان ۲۵,۰۰۰ تومان
  • افزونه نظرات حرفه ای وردپرس افزونه نظرات حرفه ای وردپرس Commentator ۱۹,۰۰۰ تومان ۱۰,۰۰۰ تومان

تخفیف 50 درصدی وی پی نگار

سیستم پرسش و پاسخ
سیستم پرسش و پاسخ وی‌پی نگار
  • محبوب
  • جدید
  • دیدگاه ها
قبلی بعدی
کانال تلگرام وی‌پی نگار
کانال تلگرام وی‌پی نگار
برجسته ترین ها
  • اضافه کردن فیلد دلخواه جدید به فرم خرید افزونه edd 3 votes, average: 5,00 out of 53 votes, average: 5,00 out of 53 votes, average: 5,00 out of 53 votes, average: 5,00 out of 53 votes, average: 5,00 out of 5 (5,00 out of 5)
  • آموزش تعریف و اضافه کردن فهرست به پوسته وردپرس 2 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 5 (5,00 out of 5)
  • انتقال ابزارک بین سایت های وردپرسی 2 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 5 (5,00 out of 5)
  • حل مشکل درخواست اطلاعات ftp در وردپرس 2 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 5 (5,00 out of 5)
  • نحوه ی تغییر سریع نام نقش های کاربری در وردپرس با بکار بردن کد 2 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 5 (5,00 out of 5)
  • کد قرار دادن عکس در پس زمینه قالب وردپرس 2 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 5 (5,00 out of 5)
  • نمایش موقعیت در نقشه گوگل در سایت با استفاده از کد 2 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 5 (5,00 out of 5)
  • نحوه ی قرار دادن QR code در سایت وردپرسی 2 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 5 (5,00 out of 5)
  • آموزش ذخیره خودکار تصاویر هنگام انتشار مطلب با Cache images 2 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 5 (5,00 out of 5)
  • آموزش مدیریت دسته بندی محصولات در ووکامرس 2 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 52 votes, average: 5,00 out of 5 (5,00 out of 5)
سیستم پرسش و پاسخ


سیستم پرسش و پاسخ وی‌پی نگار

کانال تلگرام وی‌پی نگار


کانال تلگرام وی‌پی نگار

درباره ما

وی پی نگار مرجع وردپرس فارسی،ارائه دهنده قالب وردپرس فارسی و اختصاصی با سئو و سرعت لود بسیار بالا، معرفی و آموزش افزونه وردپرس و پلاگین های کاربردی می باشد.

logo-samandehi

منابع رسمی وردپرس
  • سایت رسمی وردپرس جهانی
  • مخزن افزونه ها وردپرس
  • مخزن قالب های وردپرس
  • مخزن کد های وردپرس
پل های ارتباطی
  • location_on
    تبریز - فلکه دانشگاه - ساختمان تبریز - طبقه ۶ - واحد ۲۰
  • phone_android
    04133252264
  • perm_phone_msg
    04133253162
  • email
    info@wpnegar.ir
تمامی حقوق برای سایت وی پی نگار محفوظ می باشد.
keyboard_arrow_up