Пример #1
0
    function widget($args, $instance)
    {
        // used when the sidebar calls in the widget
        extract($args);
        $postId = $instance['partnersshown'];
        //$postW = get_post( $postId );
        if ($postId) {
            $wPartners = get_meta_partners($postId);
            if (!is_array($wPartners)) {
                echo $wPartners;
                return;
            }
            //$a = $wPartners['antenna'];
            $partners = $wPartners['partners'];
            $name = get_the_title($postId);
        } else {
            $name = __('Error', 'iftheme');
        }
        $title = apply_filters('widget_title', empty($instance['title']) ? $name : $instance['title'], $instance, $this->id_base);
        //print the widget for the widget area
        echo $before_widget;
        echo $before_title . $title . $after_title;
        ?>
		<div class="partners">
            <div class="partners_container">
            <?php 
        if (!$partners) {
            ?>
            	<div class="msg warning"><?php 
            _e("You must choose a Partner in the widget configuration:", 'iftheme');
            ?>
&nbsp;<a href="<?php 
            bloginfo('wpurl');
            ?>
/wp-admin/widgets.php\"><?php 
            _e('widgets');
            ?>
</a></div>
            <?php 
        } else {
            ?>
            <?php 
            foreach ($partners as $pPart => $pInfo) {
                $img = wp_get_attachment_image_src($pInfo['image_logo']['id'], 'partner');
                $marge = round((150 - $img[2]) / 2);
                //150 = height of the widget block
                $link = false;
                if (strlen($pInfo['link_to_partner'])) {
                    $link = true;
                }
                ?>
            	<div>
            <?php 
                if ($link) {
                    ?>
            	 <a href="<?php 
                    echo $pInfo['link_to_partner'];
                    ?>
" target="_blank"><img src="<?php 
                    echo $img[0];
                    ?>
" width="<?php 
                    echo $img[1];
                    ?>
" height="<?php 
                    echo $img[2];
                    ?>
" alt="<?php 
                    echo $pInfo['partner_title'];
                    ?>
" style="margin-top:<?php 
                    echo $marge . 'px';
                    ?>
" /></a>
            <?php 
                } else {
                    ?>
            	 <img src="<?php 
                    echo $img[0];
                    ?>
" width="<?php 
                    echo $img[1];
                    ?>
" height="<?php 
                    echo $img[2];
                    ?>
" alt="<?php 
                    echo $pInfo['partner_title'];
                    ?>
" style="margin-top:<?php 
                    echo $marge . 'px';
                    ?>
" />
            <?php 
                }
                ?>
              </div>
            <?php 
            }
            ?>
            <?php 
        }
        ?>
            </div>
        </div>
		<?php 
        echo $after_widget;
    }
Пример #2
0
get_header();
$slides = array();
if (post_type_exists('if_slider') && 'if_slider' == get_post_type()) {
    $data = get_meta_slider($post->ID);
    $antenna = $data['antenna'];
    if ($data['slides']) {
        foreach ($data['slides'] as $s => $vals) {
            $slides[$s]['title'] = $vals['slide_title'];
            $slides[$s]['link'] = $vals['url_img_slide'];
            $slides[$s]['img'] = $vals['image_slide']['id'];
        }
        $slides = array_reverse($slides);
    }
} elseif (post_type_exists('if_partner') && 'if_partner' == get_post_type()) {
    $data = get_meta_partners($post->ID);
    if (!is_array($data)) {
        echo $data;
    }
    $antenna = is_array($data) ? $data['antenna'] : NULL;
    if (is_array($data) && $data['partners']) {
        foreach ($data['partners'] as $s => $vals) {
            $part[$s]['title'] = $vals['partner_title'];
            $part[$s]['link'] = $vals['link_to_partner'];
            $part[$s]['img'] = $vals['image_logo']['id'];
        }
        $part = array_reverse($part);
        //to avoid coding twice...
        $slides = $part;
    }
} elseif ('post' == get_post_type() || 'news' == get_post_type()) {