webForumDet fria alternativet

Wordpress - går det att dölja ett kategorinamn i enskilda poster?

PHP

5 svar · 1 060 visningar · startad av MacWitty

Medlem sedan aug. 2004374 inlägg
Frågan#1

Jag skulle vilja att ett kategorinamn inte visas på sidor med enskilda poster

Wordpress 3.0.1
Tema - Fotofolio 1.0.8 (by Pupung Budi Purnama, http://wordspop.com/)
Demo: http://demo.wordspop.com/fotofolio/

På enskilda poster visas kategorinamn först, sedan post titel och författare
ex http://demo.wordspop.com/fotofolio/2009/05/laser-experiment/

Förstasidans bildvisning kräver att man anger en kategori för visning vilket har gjort att jag valt slideshow för denna. Det visas 5-6 bilder och det är tänkt att dessa ska bytas med tiden (ta bort/lägga till kategori slideshow på posterna)

Posterna ha fått sina “egna” kategorier och de som ska visas även slideshow

Att ta bort "Slideshow" i menyn i fotens mitt var inga problem (jag kan klipp och klistra) men nu visas de enskilda posterna, enligt denna modellen:

2007, Paintings, Slideshow
Blå triptyk
by Anna Andersson

Det kan även vara mer kategorier, t ex om den även ska listar på en utställning
2008, Paintings, Royal Academy, Slideshow
Blå triptyk
by Anna Andersson

Om jag bara kunde bli av med “Slideshow” skulle jag bli nöjd - övriga kategorier vill jag ha med eftersom de är informationsbärare

Så min fråga är går det att dölja/inte visa "Slideshow", i detta fall kategori med ID 13, på sidorna med enskilda poster?

Jag har varit runt på div forum och supportsidor men bara kommit så lång att det nog är single.php som bör ändras men där blir jag inte klok på alla parenteser. Detta står med start på rad 38

<?php else: ?>
				<?php if ((is_blog_cat(wptp_getopt('blog_cat' , 0))) OR in_category(wptp_getopt('blog_cat', 0))): ?>
				<div id="blog-post">
        	        		<h2><?php the_title(); ?></h2>

Att jag inte frågar på wordspops forum beror på att jag inte verkar få bli medlem - testat ett par gånger senaste veckan men det kommer inget svar Jag har kollat spamloggen men inget har fastnat där. Kanske har de semester ;)

Medlem sedan mars 2004485 inlägg
#2

Japp, kattegorin är i <h2>, så du kan ju testa kommentera bort denna.

<!-- 
<h2><?php the_title(); ?></h2>
-->

Sen om det inte funkar som tänkt är det bara lägga in igen (ta bort <!-- -->)

edit: Eller ändra på php funktionen the_title() så den bara returnerar dom kategorier du vill ha. Går säkert att använda nån stängfunktion där direkt för att ta bort det också.

edit2: ser inte att det står "Slideshow" på dom enskilda posterna...

Medlem sedan aug. 2004374 inlägg
#3

Det hände ingenting på de sidorna när jag "kommenterade bort den".
Däremot försvann titeln på de sk bloggsidorna, som har ett mer bloggaktigt utseende

Tycks som om jag är ute på fel ställe och letar :(
eller att det är det som ligger före som ska ändras på något sätt

Ursäkta jag var otydlig, länken till exemplet går till demositen - mest för att man skulle se hur en sida ser ut. Där har man valt att enbart ta bilder från en kategori (monokroma) till första sidan. Tyvärr ligger den jag håller på med bakom "Maintenance Redirect " till den gamla webbplatsen men jag försöker få till det så att konstnären själv kan lägga in bilderna innan den "öppnar".

Medlem sedan nov. 20105 inlägg
#4

När jag bara slår en kort blick på den kod klistrat in, så skulle jag gissa att det är i functions.php du ska leta...
Jag kollade runt lite men hittade inte det temat för nedladdning(letade inte mycke)
Så kan inte kolla igenom, men klistra in functions.php så kan jag kolla.

Medlem sedan aug. 2004374 inlägg
#5

Här kommer Theme Functions (functions.php)

<?php
/**
 * Fotofolio 1.0.6
 * Moozaic
 * http://ich.schrei.be
 */

$themename = 'FotoFolio';
$shortname = 'ftfl';

$options = array (
        array(  "name" => "Show home title?",
            "desc" => "Show the title of your fotofolio website",
            "id"   => $shortname."_show_welcome_title",
            "std"  => wptp_getopt('show_welcome_title', 0),
            "type" => "checkbox"),
	array(  "name" => "Title",
            "desc" => "The title of your fotofolio website",
            "id"   => $shortname."_welcome_title",
            "std"  => $themename,
            "type" => "text"),
	array(  "name" => "Logo",
            "desc" => "Enter URL for your Logo",
            "id"   => $shortname."_welcome_logo",
            "std"  => wptp_getopt('home_logo', 0),
            "type" => "text"),
        array(  "name" => "Show blog description?",
            "desc" => "Show the blog description next to the logo?",
            "id"   => $shortname."_show_blog_desc",
            "std"  => wptp_getopt('show_blog_desc', 0),
            "type" => "checkbox"),
        array(  "name" => "Show welcome message under home title?",
            "desc" => "Show brief introduction into your fotofolio theme",
            "id"   => $shortname."_show_welcome_message",
            "std"  => wptp_getopt('show_welcome_message', 0),
            "type" => "checkbox"),
	array(  "name" => "Message",
            "desc" => "Brief introduction into your fotofolio theme",
            "id"   => $shortname."_welcome_message",
            "std"  => wptp_getopt('home_msg', 0),
            "type" => "textarea"),
        array(  "name" => "Show Author's Name?",
            "desc" => "Show the author's numaber under home title, and photo post title",
            "id"   => $shortname."_show_author",
            "std"  => wptp_getopt('show_author', 0),
            "type" => "checkbox"),
        array(  "name" => "Show post publish date under photo post title?",
            "desc" => "Show the post publish date under photo post title",
            "id"   => $shortname."_show_photo_post_date",
            "std"  => wptp_getopt('show_photo_post_date', 0),
            "type" => "checkbox"),
	array(  "name" => "Full Name",
            "desc" => "your Full Name eg. Pupung Budi Purnama",
            "id"   => $shortname."_full_name",
            "std"  => wptp_getopt('author', 0),
            "type" => "text"),
	array(  "name" => "Short Biography",
            "desc" => "Your short biography",
            "id"   => $shortname."_short_bio",
            "std"  => wptp_getopt('bio', 0),
            "type" => "textarea"),
        array(  "name" => "Show Gravatar",
            "desc" => "Show your gravatar in bottom bar?",
            "id"   => $shortname."_show_avatar",
            "std"  => wptp_getopt('show_avatar', 0),
            "type" => "checkbox"),
	array(  "name" => "Your Email",
            "desc" => "your email, for displaying gravatar, register in gravatar.com",
            "id"   => $shortname."_email",
            "std"  => wptp_getopt('email', 0),
            "type" => "text"),
        array(  "name" => "Twitter Username",
            "desc" => "your twitter username (without @). It require 'Twitter for Wordpress' plugin",
            "id"   => $shortname."_twitter",
            "std"  => wptp_getopt('twitter', 0),
            "type" => "text"),
        array(  "name" => "Twitter Title",
            "desc" => "The title of above twitter tweet",
            "id"   => $shortname."_twitter_title",
            "std"  => wptp_getopt('twitter_title', 0),
            "type" => "text"),
	array(  "name" => "Front page slideshow",
            "desc" => "Choose a category to play slideshow on front page",
            "id"   => $shortname."_home_slideshow",
            "std"  => wptp_getopt('slide_cat', 0),
            "type" => "select",
            "options" => mooz_get_categories()),
	array(  "name" => "Slideshow Number",
            "desc" => "Number of Slideshow, Best is 5, Think about loading time!",
            "id"   => $shortname."_num_slideshow",
            "std"  => wptp_getopt('slide_num', 0),
            "type" => "select",
            "options" => array('1' => "1","2","3","4","5","6","7")),
	array(  "name" => "Latest Additions number",
            "desc" => "Latest additions number show on homepage",
            "id"   => $shortname."_num_latest",
            "std"  => wptp_getopt('latest_num', 0),
            "type" => "select",
            "options" => array('1' => "1","2","3","4","5","6","7","8","9","10","11","12")),
        array(  "name" => "Show posts list on photo category page",
            "desc" => "Show the posts list as well on photo categories.",
            "id"   => $shortname."_show_post_list_in_photo_cat",
            "std"  => wptp_getopt('show_post_list_in_photo_cat', 0),
            "type" => "checkbox"),
        array(  "name" => "Blog Category",
            "desc" => "Select a parent category used for blog posts. Posts under this category my treat as regular blog layout",
            "id"   => $shortname."_blog_category",
            "std"  => wptp_getopt('blog_cat', 0),
            "type" => "select",
            "options" => mooz_get_categories()),
        array(  "name" => "Use regular blog layout for blog category",
            "desc" => "Show the blog category like regular blog.",
            "id"   => $shortname."_use_blog_style_for_blog_cat",
            "std"  => wptp_getopt('use_blog_style_for_blog_cat', 0),
            "type" => "checkbox"),
        array( "name" => "Post navigation in same category?",
            "desc" => "Enable this option will restict the post navigation within same category level",
            "id"   => $shortname."_nav_in_same_cat",
            "std"  => wptp_getopt('nav_in_same_cat', 0),
            "type" => "checkbox"),
        array(  "name" => "Navigation caption for NEXT",
            "desc" => "Enter the caption or image HTML code for NEXT natvigation",
            "id"   => $shortname."_nav_next_value",
            "std"  => wptp_getopt('nav_next_value', 0),
            "type" => "text"),
        array(  "name" => "Navigation caption for PREVIOUS",
            "desc" => "Enter the caption or image HTML code for PREVIOUS natvigation",
            "id"   => $shortname."_nav_previous_value",
            "std"  => wptp_getopt('nav_previous_value', 0),
            "type" => "text"),
        array(  "name" => "Define Post Custom Field name for Post Thumbnail Image.",
            "desc" => "Enter the desired custom field name in blog post for display post thumbnail (Not overriding the photo post thumbnail).",
            "id"   => $shortname."_post_thumbnail_meta",
            "std"  => wptp_getopt('post_thumbnail_meta', 0),
            "type" => "text"),
        array(  "name" => "Define Post Custom Field name for video post",
            "desc" => "Enter the desired custom field name in blog post, tell the theme only display post excerpt in right side panel. It will be useful when you are posting embed video and keep portfolio layout. Example: Enter the field name [video_post] here, and then add a custom field named [video_post] value [yes] in your post. Thats it. Finally, remember type your text content in Post Excerpt",
            "id"   => $shortname."_post_have_video_meta",
            "std"  => wptp_getopt('post_have_video_meta', 0),
            "type" => "text"),
        array(  "name" => "Define Post Custom Field name for photographer name under individual photo.",
            "desc" => "Enter the desired custom field key name in blog post for display the photographer name under the post title.",
            "id"   => $shortname."_post_photographer_meta",
            "std"  => wptp_getopt('post_photographer_meta', 0),
            "type" => "text"),
	array( "name" => "JS RollOver OFF",
            "desc" => "Turn OFF JavaScript rollover effect",
            "id"   => $shortname."_norollover_js",
            "std"  => wptp_getopt('norolljs', 0),
            "type" => "checkbox"),
	array(  "name" => "Enable Comment",
            "desc" => "Enable Comment Feature",
            "id"   => $shortname."_comment",
            "std"  => wptp_getopt('comment', 0),
            "type" => "checkbox"),
    array ( "name" => "TimThumb Use URL",
            "desc" => "Use URL to generate image. Try switching this option if you have problem displaying image<br />Default is to use <strong>PATH</strong> (recommended)",
            "id"   => $shortname."_timthumb_url",
            "std"  => wptp_getopt('tim_url', 0),
            "type" => "checkbox"),
	array(  "name" => "Make the photo post's image clickable",
            "desc" => "Link the image to orginal image file in photo post!",
            "id"   => $shortname."_img_clickable",
            "std"  => wptp_getopt('img_clickable', 0),
            "type" => "checkbox"),
        array(  "name" => "Class/rel for the photo post image",
            "desc" => "Enter the desired class/rel for the post image (Not for blog post image). Must quote the value with ' ' <br /> For example <br />shutter reloaded: class='shutterset' <br />Lightbox2: class='shutterset' rel='lightbox' <br />Thickbox: class='thickbox no_icon'",
            "id"   => $shortname."_img_class_rel",
            "std"  => wptp_getopt('img_class_rel', 0),
            "type" => "text"),
	array(  "name" => "Image Resize",
            "desc" => "MAX WIDTH - To calculate aspect ratio. If set to 0, it will use default value, which is <strong>450</strong>px",
            "id"   => $shortname."_resize_width",
            "std"  => wptp_getopt('img_width', 0),
            "type" => "text"),
	array(  "name" => "",
            "desc" => "MAX HEIGHT - To calculate aspect ratio. If set to 0, it will use default value, which is <strong>600</strong>px",
            "id"   => $shortname."_resize_height",
            "std"  => wptp_getopt('img_height', 0),
            "type" => "text"),
        array(  "name" => "Optimized Image Width",
            "desc" => "When the image width equal or wider then this value, the right hand side legend panel will wrap under the image.",
            "id"   => $shortname."_opt_img_width",
            "std"  => wptp_getopt('opt_img_width', 0),
            "type" => "text"));
$tmp_array = array (
    array ( "name" => "Show Properties",
            "desc" => "EXIF: Camera Model",
            "id"   => $shortname."_exif_cam",
            "std"  => 0,
            "type" => "checkbox"),
    array ( "name" => "",
            "desc" => "EXIF: Exposure",
            "id"   => $shortname."_exif_shu",
            "std"  => 0,
            "type" => "checkbox"),
    array ( "name" => "",
            "desc" => "EXIF: Aperture",
            "id"   => $shortname."_exif_ape",
            "std"  => 0,
            "type" => "checkbox"),
    array ( "name" => "",
            "desc" => "EXIF: Focal Length",
            "id"   => $shortname."_exif_foc",
            "std"  => 0,
            "type" => "checkbox"),
    array ( "name" => "",
            "desc" => "EXIF: ISO Speed",
            "id"   => $shortname."_exif_iso",
            "std"  => 0,
            "type" => "checkbox"));

if(extension_loaded('exif'))
    $options = mooz_load_exif_option();

function mooz_fotofolio_init() {
    global $themename, $shortname, $options;
    if(isset($_GET['page']) && $_GET['page'] == basename( __FILE__ )) {
        if(isset($_REQUEST['action']) && 'save' == $_REQUEST['action']) {
            check_admin_referer('fotofolio-setting');
            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;
        } elseif(isset($_REQUEST['action']) && 'reset' == $_REQUEST['action']) {
            check_admin_referer('fotofolio-setting');
            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__ ), 'fotofolio_panel');
}

function mooz_load_exif_option() {
    global $options, $tmp_array;
    for($i = 0; $i < count($tmp_array); ) { $options[] = $tmp_array[$i]; $i++; }
    return $options;
}

function fotofolio_panel() {
    global $themename, $shortname, $options;
    if(isset($_REQUEST['saved']) && ($_REQUEST['saved'])) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
    if(isset($_REQUEST['reset']) && ($_REQUEST['reset'])) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
?>
<div class="wrap">
<h2><?php echo $themename; ?> settings</h2>
<form method="post">
<?php wp_nonce_field('fotofolio-setting'); ?>
        <table width="100%" border="0" style="background-color:#efefef; padding:5px 10px;">
            <tr>
                <td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;">Theme Settings</h3></td>
            </tr>
            <table width="100%" border="0" style="padding:10px;">
                <tr>
                    <td width="20%" rowspan="1" style="padding-top:10px" valign="middle"></td>
                </tr>
<?php foreach($options as $value) {
    switch ($value['type']) {
        case 'text': ?>
        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if(get_option($value['id']) != "") { echo htmlentities(trim(stripcslashes(get_option($value['id'])))); } else { echo $value['std']; } ?>" /></td>
        </tr>
        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr>
        <tr>
            <td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td>
        </tr>
        <tr><td colspan="2">&nbsp;</td></tr>
		<?php break;
		case 'textarea': ?>
        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:400px; height:100px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if(get_option($value['id']) != "") { echo trim(stripcslashes(get_option($value['id']))); } else { echo $value['std']; } ?></textarea></td>
        </tr>
        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr>
        <tr>
        <td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td>
        </tr>
        <tr><td colspan="2">&nbsp;</td></tr>
		<?php break;
		case 'select': ?>
        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php $default = $value['std']; if(!get_option($value['id'])) { $selected = $default; } else { $selected = get_option($value['id']); } foreach($value['options'] as $key => $val) { ?><option value="<?php echo $val ?>"<?php if($val == $selected) echo 'selected="selected"'; ?>><?php echo $key; ?></option><?php } ?></select></td>
        </tr>
        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr>
        <tr>
            <td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td>
        </tr>
        <tr><td colspan="2">&nbsp;</td></tr>
        <?php break;
        case "checkbox": ?>
        <tr>
            <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
            <td width="80%"><?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else { $checked = ''; } ?>
            <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="1" <?php echo $checked; ?> />
            </td>
        </tr>
        <tr>
            <td><small><?php echo $value['desc']; ?></small></td>
        </tr>
        <tr>
            <td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td>
        </tr>
        <tr><td colspan="2">&nbsp;</td></tr>
        <?php break;
        } 
    } ?>
        <tr>
            <td width="20%" style="padding-top:10px" valign="middle"><input type="submit" name="save" value=" Save Changes " class="button-primary" /><input type="hidden" name="action" value="save" /></form></td>
            <td width="80%" style="padding-top:10px" valign="middle"><form method="post"><?php wp_nonce_field('fotofolio-setting'); ?><input name="reset" id="reset" type="submit" value="Reset" class="button" /><input type="hidden" name="action" id="reset" value="reset" /></form></td>
        </tr>
        </table><br />
<!--</table>-->
<p class="donate">
<strong>Enjoying the theme? Please <a href="http://wordspop.com/donate/" target="_blank">donate the author.</a></strong>
</p>
<?php
}

function wptp_has_img() {
	global $id;
	$post_id = (int) $id;
    $attachment_id = wptp_get_image_attachment($post_id);
    if(empty($attachment_id))
        return false;
    return true;
}

function wptp_getopt($what, $echo = true) {
    global $shortname, $themename, $version;
    if(empty($what)) return;
    switch($what) {
        case 'show_blog_desc':
            $data = (int) stripcslashes(get_option($shortname.'_show_blog_desc'));
            if(empty($data)) $data = 0;
        break;
        case 'header_desc';
            $data = stripcslashes(get_option('blogdescription'));
            if(empty($data)) $data = 'Your blog descroption!';
        break;
        case 'show_welcome_title':
            $data = (int) get_option($shortname.'_show_welcome_title');
            if(empty($data)) $data = 0;
        break;
        case 'home_title':
            $data = trim(stripcslashes(get_option($shortname.'_welcome_title')));
            if(empty($data)) $data = get_option('blogname');
        break;
        case 'home_logo':
            $data = get_option($shortname.'_welcome_logo');
            if(empty($data)) $data = get_template_directory_uri().'/images/logo.png';
        break;
        case 'show_welcome_message':
            $data = (int) get_option($shortname.'_show_welcome_message');
            if(empty($data)) $data = 0;
        break;
        case 'home_msg':
            $data = trim(stripcslashes(get_option($shortname.'_welcome_message')));
            if(empty($data)) $data = 'Welcome to '.wptp_getopt('author', 0).' blog!';
        break;
        case 'show_author':
            $data = (int) get_option($shortname.'_show_author');
            if(empty($data)) $data = 0;
        break;
        case 'author':
            $data = trim(stripcslashes(strip_tags(get_option($shortname.'_full_name'))));
            if(empty($data)) $data = "Author Name";
        break;
        case 'show_avatar':
            $data = (int) get_option($shortname.'_show_avatar');
            if(empty($data)) $data = 0;
        break;
        case 'show_photo_post_date':
            $data = (int) get_option($shortname.'_show_photo_post_date');
            if(empty($data)) $data = 0;
        break;
        case 'email':
            $data = stripcslashes(strip_tags(get_option($shortname.'_email')));
            if(empty($data)) $data = 'youname@youremail.com';
        break;
        case 'twitter':
            $data = strip_tags(get_option($shortname.'_twitter'));
            if(empty($data)) $data = 'Twitter Username';
        break;
        case 'twitter_title':
            $data = stripcslashes(strip_tags(get_option($shortname.'_twitter_title')));
            if(empty($data)) $data = 'Tweets';
        break;
        case 'bio':
            $data = trim(stripcslashes(get_option($shortname.'_short_bio')));
            if(empty($data)) $data = 'Author information';
        break;
        case 'slide_cat':
            $data = (int) get_option($shortname.'_home_slideshow');
            if(empty($data)) $data = 1;
        break;
        case 'slide_num':
            $data = (int) get_option($shortname.'_num_slideshow');
            if(empty($data)) $data = 2;
        break;
        case 'latest_num':
            $data = (int) get_option($shortname.'_num_latest');
            if(empty($data)) $data = 4;
        break;
        case 'show_post_list_in_photo_cat':
            $data = (int) get_option($shortname.'_show_post_list_in_photo_cat');
            if(empty($data)) $data = 0;
        break;
        case 'blog_cat':
            $data = (int) get_option($shortname.'_blog_category');
            if(empty($data)) $data = 1;
        break;
        case 'use_blog_style_for_blog_cat':
            $data = (int) get_option($shortname.'_use_blog_style_for_blog_cat');
            if(empty($data)) $data = 0;
        break;
        case 'nav_in_same_cat':
            $data = (int) get_option($shortname.'_nav_in_same_cat');
            if(empty($data)) $data = 0;
        break;
        case 'nav_next_value':
            $data = stripcslashes(get_option($shortname.'_nav_next_value'));
            if(empty($data)) $data = 'NEXT';
        break;
        case 'nav_previous_value':
            $data = stripcslashes(get_option($shortname.'_nav_previous_value'));
            if(empty($data)) $data = 'PREVIOUS';
        break;
        case 'post_thumbnail_meta':
            $data = strip_tags(get_option($shortname.'_post_thumbnail_meta'));
            if(empty($data)) $data = 'post_thumbnail';
        break;
        case 'post_have_video_meta':
            $data = strip_tags(get_option($shortname.'_post_have_video_meta'));
            if(empty($data)) $data = 'video_post';
        break;
        case 'post_photographer_meta':
            $data = stripcslashes(strip_tags(get_option($shortname.'_post_photographer_meta')));
            if(empty($data)) $data = 'photographer';
        break;
        case 'norolljs':
            $data = (int) get_option($shortname.'_norollover_js');
            if(empty($data)) $data = 0;
        break;
        case 'comment':
            $data = (int) get_option($shortname.'_comment');
            if(empty($data)) $data = 0;
        break;
        case 'tim_url':
            $data = (int) get_option($shortname.'_timthumb_url');
            if(empty($data)) $data = 0;
        break;
        case 'img_clickable':
            $data = (int) get_option($shortname.'_img_clickable');
            if(empty($data)) $data = 0;
        break;
        case 'img_class_rel':
            $data = stripcslashes(strip_tags(get_option($shortname.'_img_class_rel')));
            if(empty($data)) $data = ' ';
        break;
        case 'img_width':
            $data = (int) get_option($shortname.'_resize_width');
            if(empty($data) || 0 == $data) $data = 450;
        break;
        case 'img_height':
            $data = (int) get_option($shortname.'_resize_height');
            if(empty($data) || 0 == $data) $data = 600;
        break;
        case 'opt_img_width':
            $data = (int) get_option($shortname.'_opt_img_width');
            if(empty($data) || 0 == $data) $data = 500;
        break;
    }
    if($echo)
        echo $data;
    return $data;
}

function mooz_get_categories() {
    $ftfl_categories = get_categories();
    $ftfl_categories_list = array();
    foreach( $ftfl_categories as $ftflcat ){
        $ftfl_categories_list[$ftflcat->name] = $ftflcat->cat_ID;
    }
    return $ftfl_categories_list;
}

/* Forget to mention. This code was originally taken from Exifer library (Jake Olefsky). */
function ConvertToFraction($v, &$n, &$d) {
    $MaxTerms = 15;
    $MinDivisor = 0.000001;
    $MaxError = 0.00000001;
    $f = $v;
    $n_un = 1;
    $d_un = 0;
    $n_deux = 0;
    $d_deux = 1;
    for($i = 0; $i<$MaxTerms; $i++) {
        $a = floor($f);
        $f = $f - $a;
        $n = $n_un * $a + $n_deux;
        $d = $d_un * $a + $d_deux;
        $n_deux = $n_un;
        $d_deux = $d_un;
        $n_un = $n;
        $d_un = $d;
        if($f < $MinDivisor)
            break;
        if(abs($v - $n/$d) < $MaxError)
            break;
        $f = 1 / $f;
	}
}

function mooz_get_meta($attachment_id) {
    global $shortname;
    $metas = array();
    $attachment_id = (int) $attachment_id;
    if(!$attachment_id) return $metas;
    $imgmt = wp_get_attachment_metadata($attachment_id);
    if(empty($imgmt['image_meta'])) return $metas;

    if(get_option($shortname.'_exif_cam')) {
        $metas['cam'] = array(
            "key" => "Camera",
            "val" => $imgmt['image_meta']['camera']);
    }
    if(get_option($shortname.'_exif_shu')) {
        $xshu = $imgmt['image_meta']['shutter_speed'];
        if($xshu > 1) $xshu = floor($xshu);
        if($xshu > 0) {
            $n=0; $d=0;
            ConvertToFraction($xshu, $n, $d);
            if($n >= 1 && $d == 1) $num = $n;
            else $num = $n.'/'.$d;
        } else {
            $num = $num;
        }
        $metas['shu'] = array(
            "key" => "Exposure",
            "val" => $xshu." sec (".$num.")");
    }
    if(get_option($shortname.'_exif_ape')) {
        $metas['ape'] = array(
            "key" => "Aperture",
            "val" => 'f/'.$imgmt['image_meta']['aperture']);
    }
    if(get_option($shortname.'_exif_foc')) {
        $metas['foc'] = array(
            "key" => "Focal Length",
            "val" => $imgmt['image_meta']['focal_length'].' mm');
    }
    if(get_option($shortname.'_exif_iso')) {
        $metas['iso'] = array(
            "key" => "ISO speed",
            "val" => $imgmt['image_meta']['iso']);
    }
    if(count($metas) > 0) {
        foreach($metas as $value) {
	        echo "<strong>".$value['key'].":</strong> ".$value['val']."<br />";
        }
    }
}

function mooz_get_ratio($id, $max_width = '', $max_height = '') {
	$img_data = wp_get_attachment_metadata($id);
	if(empty($img_data) || 0 == $img_data) return false;
	$width = $img_data['width'];
	$height = $img_data['height'];
    if($max_width > $width) $max_width = $width;
    if($max_height > $height) $max_height = $height;
    $xscale = $width/$max_width;
    $yscale = $height/$max_height;
    if($yscale > $xscale) {
        $new_width  = round($width * (1/$yscale));
        $new_height = round($height * (1/$yscale));
    } else {
        $new_width  = round($width * (1/$xscale));
        $new_height = round($height * (1/$xscale));
    }
    return array('w' => $new_width, 'h' => $new_height);
}

function mooz_get_base_path($id) {
    $doc_root = $_SERVER['DOCUMENT_ROOT'];
    $doc_root = str_replace('\\', '/', $doc_root);
    $xpath = get_attached_file($id);
    $xpath = str_replace('\\', '/', $xpath);
    return $base_img = str_replace($doc_root, '', $xpath);
}

function mooz_get_base_url($id) {
	global $wpdb;
	$post_id = (int) $id;
    return $url = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE ID = $post_id");
}

function wptp_get_image_attachment($post_id) {
    global $wpdb;
    $post_id = (int) $post_id;
    if(0 == $post_id) return;
    return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = $post_id AND post_type = 'attachment' AND post_mime_type LIKE 'image%' ORDER BY post_date ASC LIMIT 1");
}

function mooz_image_predata($post_id) {
	$post_id = (int) $post_id;
	if(!$post_id) return false;
	$max_width = wptp_getopt('img_width', 0);
	$max_height = wptp_getopt('img_height', 0);
	$switch = wptp_getopt('tim_url', 0);
    $image['id'] = wptp_get_image_attachment($post_id);
    if(empty($image['id'])) return false;
    if(empty($switch))
        $image['path'] = mooz_get_base_path($image['id']);
    else
        $image['path'] = mooz_get_base_url($image['id']);
    $image['size'] = mooz_get_ratio($image['id'], $max_width, $max_height);
    if(false == $image['size'])
        return false;
    return $image;
}

add_action('admin_menu', 'mooz_fotofolio_init');

/*  Sidebar */
if ( function_exists('register_sidebars') ) {
register_sidebars(1);
register_sidebars(3, array('name'=>'Bottom Widget %d'));
}

/* Customized search form layout */
function widget_theme_search() {
?>
<form id="sidebar-searchform" method="get" action="<?php bloginfo('wpurl') ?>/index.php">
	<input type="text" name="s" id="ss" value="Search" />
</form>
<?php
}

if ( function_exists('register_sidebar_widget') )
    register_sidebar_widget(__('Search'), 'widget_theme_search');

/* Excerpt Length for post listing */

function new_excerpt_length($length) {
	return 30;
}
add_filter('excerpt_length', 'new_excerpt_length');

/* Is it blog parent */

function in_parent_category($cats, $_post = null)
{
        foreach ((array) $cats as $cat)
        {
                $descendants = get_term_children((int) $cat, "category");
                if ($descendants && in_category($descendants, $_post))
                        return true;
        }
        return false;
}

/* Is it blog post */
function is_blog_cat($blog_cat) {
	foreach((get_the_category($cat)) as $category) {
                if(($category->cat_ID == $blog_cat) OR ($category->category_parent == $blog_cat))
		return true;
	}
	return false;
}

?>
<? if(!function_exists(amt_cif)) { require_once('functions.wp-amt.php'); } ?>
Medlem sedan nov. 20105 inlägg
#6

Finns det nån fil i temat som inte heter nått av följande:
singel.php, index.php, page.php, functions.php, style.css, header.php, footer.php, archive.php???
Så svårt o kolla när man inte kan tanka ner temat...

285 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
127 ms — deklarationer (db)
0 ms — hämta statistik (cache)
155 ms — hämta tråd, inlägg och bilagor (db)
116 ms — ändringar (db)