Function.php kodu
function mtheme_thumb($postid=1, $size='thumbnail', $attributes='') {
if ($postid<1) $postid = get_the_ID();
if ($images = get_children(array(
'post_parent' => $postid,
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image', )))
foreach($images as $image) {
$thumbnail=wp_get_attachment_image_src($image->ID, $size);
?>
/>
}
else {
echo ' echo '/images/no-attachment.gif>';
}
}
if ( function_exists('register_sidebars') )
register_sidebars(1);
$themename = "Mobile Theme";
$shortname = "mob";
$options = array (
array(
"name" => "Mobile Theme Options",
"type" => "title"),
array(
"type" => "open"),
array(
"name" => "Theme Color",
"desc" => "Choose the base color for your mobile theme!",
"id" => $shortname."_color",
"std" => "C00000",
"type" => "colorjs"),
array(
"name" => "Theme Width",
"desc" => "Choose a width for the theme. Enter 100% for full width or define the width in pixels like 320px",
"id" => $shortname."_width",
"std" => "360px",
"type" => "text"),
array(
"type" => "close")
);
/*Add a Theme Options Page*/
function mytheme_add_admin() {
global $themename, $shortname, $options;
if ( $_GET['page'] == basename(__FILE__) ) {
if ( 'save' == $_REQUEST['action'] ) {
foreach ($options as $value) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
foreach ($options as $value) {
if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
header("Location: themes.php?page=functions.php&saved=true");
die;
} else if( 'reset' == $_REQUEST['action'] ) {
foreach ($options as $value) {
delete_option( $value['id'] ); }
header("Location: themes.php?page=functions.php&reset=true");
die;
}
}
add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
/*Adding scripts*/
function admin_js(){
if ( $_GET['page'] == basename(__FILE__) ) {
?>
<script>/js/jscolor.js"></script>
}
function mytheme_admin() {
global $themename, $shortname, $options;
if ( $_REQUEST['saved'] ) echo ''.$themename.' settings saved.
';
if ( $_REQUEST['reset'] ) echo ''.$themename.' settings reset.
';
?>
}
function mytheme_wp_head() { ?>
add_action('wp_head', 'mytheme_wp_head');
add_action('admin_head', 'admin_js');
add_action('admin_menu', 'mytheme_add_admin'); ?>
Buda indexte görülecek öne çıkarılmış resimin kodu:
Acil yardım.