Wordpress kurulu sitede SEO için site yüklenme hızlandırma çalışmalarında, Wordpress Header bölümüne .js .css gibi kodları gönderen wp kodlarını değiştirmek lazım oldu. Bi inceleyelim.
Önce bulduğumuz kodları yazalım.
Examples
------------
Add custom css within head section using wp_head action.
add_action('wp_head','hook_css');
function hook_css()
{
$output="<style> .wp_head_example { background-color : #f1f1f1; } </style>";
echo $output;
}
----------
Add custom javascript within head section using wp_head action.
----------
add_action('wp_head','hook_javascript');
function hook_javascript()
{
$output="<script> alert("Page is loading..."); </script>";
echo $output;
}
----------
Kaynak : http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head
Wordpress Footer veya Header bölümüne scritp veya html kodu ekleme kodları.
Add PHP to your head -( Header 'a PHP kodu ekleme.)
-----------
// Add scripts to wp_head()
function child_theme_head_script() {
// Your PHP goes here
}
add_action( 'wp_head', 'child_theme_head_script' );
------------
Add HTML to your head - (Header 'a HTML kodu ekleme.)
------------
// Add scripts to wp_head()
function child_theme_head_script() { ?>
<!-- Your HTML goes here -->
<?php }
add_action( 'wp_head', 'child_theme_head_script' );
----------
Bu kodları hazırladığımız plugin içine veya başka bir yere yazacağız. (function.phd) de kullanılabilir diye düşünüyorum. Benim niyetim pluginlerin header eklediklerini footer bölümüne göndermek, şimdi de footer bölümüne gönderecek foknsiyon kodunu bulalım.
--------------
<?php
function your_function() {
echo '<p>This is inserted at the bottom</p>';
}
add_action('wp_footer', 'my_function');
?>
-----------------
<?php
function your_function() {
echo '<p>This is inserted at the bottom</p>';
}
add_action('wp_footer', 'your_function', 100);
?>
-------------------
KAYNAK http://codex.wordpress.org/Plugin_API/Action_Reference/wp_footer
Bu kodları buldum ancak ben plugin de değişiklik yaparak, head bölümünde yer alan css ve js dosyalarını foot bölümüne göndermek istiyordum. Konuyu şimdilik tamamlayamasamda kullandığımı pluginin
add_action('wp_print_styles', array(&$this, 'WP_print_styles'));
yazılı satırını aşağıdaki gibi yaptım.
add_action('wp_footer', array(&$this, 'WP_print_styles'));
Şimdilik işin bir kısmını halletim ancak asıl istediğim olmadı. Konuyuda bir yere bağlayamadık.
Bu çalışmaları kamuya açık çalışma notlarım olduğunu unutmayın. Sadece öğrendiklerimi paylaşıyorum.