This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function create_example_post_type() { | |
$labels = array( | |
'name' => 'Exempel', | |
'singular_name' => 'Exempel', | |
'add_new_item' => 'Lägg till nytt exempel', | |
'edit_item' => 'Redigera exempel', | |
'new_item' => 'Nytt exempel', | |
'view_item' => 'Visa exempel', | |
'search_items' => 'Sök bland exempel', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* definiera en array */ | |
$test = array('key1' => 'hej', 42 => 'då'); | |
/* skriver ut 'hej' */ | |
echo $test['key1']; | |
/* skriver ut 'då' */ | |
echo $test[42]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function test($argument1, $argument2) { | |
echo $argument1 . $argument2; | |
} | |
/* kalla funktionen */ | |
test('hej', 'då'); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* lägger till inställningar */ | |
function theme_admin_init() { | |
register_setting('exempel_options', 'exempel_options', 'exempel_options_validate'); | |
add_settings_section('exempel_main', 'Exempelinställningar', 'exempel_section_text', 'exempel'); | |
add_settings_field('exempelfarg', 'Välj en färg', 'theme_setting_exempelfarg', 'exempel', 'exempel_main'); | |
} | |
/* ser till att funktionen theme_admin_init() körs i rätt sammanhang */ | |
add_action('admin_init', 'theme_admin_init'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_theme_menu() { | |
/* lägger till en inställningsmeny med id 'exempel-id'. För att visa inställningssidan körs funktionen 'my_options()' i detta fall */ | |
add_theme_page('Exempel', 'Exempel', 'manage_options', 'exempel-id', 'my_options'); | |
} | |
/* ser till att funktionen my_theme_menu() körs i rätt sammanhang, dvs. när adminstrationsmenyerna behöver hämtas */ | |
add_action('admin_menu', 'my_theme_menu'); | |
/* returnerar en inställningssida att visa */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Rundade hörn */ | |
.rounded { | |
border-radius: 5px; | |
} | |
/* Skuggade div:s och andra element, flera alternativ behövs eftersom opera, mozilla och webkit-browsers tolkar CSS något olika */ | |
.box-shadowed { | |
-moz-box-shadow: 3px 3px 5px 6px #ccc; | |
-webkit-box-shadow: 3px 3px 5px 6px #ccc; | |
box-shadow: 3px 3px 5px 6px #ccc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* #container är en div som innehåller allt synligt innehåll på sidan */ | |
#container { | |
width: 960px; /* fixerar totala bredden till 960 pixlar */ | |
margin: auto; /* automatiska marginaler, om sidan visas i ett fönster med större bredd än 960 pixlar så centreras innehållet */ | |
} | |
/* .col-half är divs som är till för att lägga ut kolumner med 50% av sidans bredd */ | |
.col-half { | |
display: table-cell; /* tillåter flera div:s att ligga som celler i en tabell bredvid varandra */ | |
width: 50%; /* fixerar bredden till halva sidbredden */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package WordPress | |
* @subpackage test | |
*/ | |
get_header(); ?> | |
<div id="main" role="main"> | |
<div class="col-half"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* importerar typsnitt från en fil 'Anivers.otf' i samma mapp som style.css */ | |
@font-face { | |
font-family: Anivers; | |
src: url('Anivers.otf'); | |
} | |
/* sätter typsnitt, storlek och justering för hela dokumentet */ | |
html, body { | |
font-family: Helvetica, sans-serif; | |
font-size:0.8em; /* em är storlek relativt webbläsarens normalstorlek. Användbart för läsbarhet */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php get_sidebar(); ?> |