public function registerExtraCSS() { $sc = is_at(); $this->register($sc); // year, month, date will used archive as sub stylesheets if ($sc == wpiSection::YEAR || $sc == wpiSection::MONTH || $sc == wpiSection::DAY) { $this->register(wpiSection::ARCHIVE); } if ($sc == wpiSection::PAGE || $sc == wpiSection::SINGLE) { $this->register('comments'); // attachment is inside single & page so it must be separated // from the above conditional } elseif ($sc == wpiSection::ATTACHMENT) { $this->register('comments'); } $selectors = str_rem('-foaf-Document', wpi_get_body_class()); $selectors = str_rem('archive', $selectors); $selectors = explode(" ", $selectors); foreach ($selectors as $tag) { $this->register($tag); } unset($selectors, $tag); $this->Avatar = new wpiGravatar(); $this->Avatar->filterCSS($sc); if (wpi_option('text_dir') == 'rtl') { $this->register('rtl'); } if (isset($this->section[$sc])) { foreach ($this->section[$sc] as $tag) { $this->register($tag); } } }
/** * Post summary, active at single & page */ function wpi_widget_post_summary() { global $post, $commentdata; $section = is_at(); $name = 'about-articles'; $title = $section == 'single' ? 'About this articles' : 'About'; wpi_widget_start($title, $name); $title = apply_filters('the_title', $post->post_title); $link = _t('a', WPI_BLOG_NAME, array('href' => apply_filters(wpiFilter::FILTER_LINKS, WPI_URL_SLASHIT), 'title' => WPI_BLOG_NAME, 'rel' => 'home')); $hdate = apply_filters('postdate', $post->post_date); $date = _t('span', get_the_time(__('l M jS, Y', WPI_META)), array('class' => 'published-date', 'title' => $hdate)); $output = sprintf(__('<big>Y</big>ou’re currently reading “ <strong class="fw-">%1s</strong>”. This entry appeared in %2s on %3s.', WPI_META), $title, $link, $date); t('p', $output, array('class' => 'meta-title')); ?> <p class="meta-published-date"> It was last updated at <span class="date"><?php the_modified_time('H:i a'); ?> </span> on <span class="date"><?php the_modified_time('M jS o'); ?> </span> approximately <sup>≅</sup> <span class="last-updated hdate"><?php echo wpi_get_relative_date($post->post_modified); ?> </span>.</p> <?php do_action('widget_single_summary_after'); wpi_widget_end(); }
function wpi_cat_links($echo = 1, $index = false, $separator = '¸') { global $wp_query; $section = is_at(); $pid = false; if ($section == wpiSection::ATTACHMENT) { $pid = $wp_query->post->post_parent; } $cats = get_the_category($pid); $options = array('class' => 'cat-link ttip dc-subject foaf-isPrimaryTopicOf', 'href' => '#content', 'rel' => 'category foaf.topic', 'title' => 'category', 'rev' => 'site:archive'); if (is_bool($index)) { $links = "\n"; $ismore = false; $cnt = count($cats); if ($cnt >= 0) { $ismore = true; $endcnt = $cnt - 1; } $i = 1; foreach ($cats as $cat) { $options['href'] = apply_filters('wpi_links_' . $section, get_category_link($cat->cat_ID)); $options['title'] = $cat->cat_name . ' | ' . $cat->count . ' articles in this category'; $links .= _t('a', $cat->name, $options); if ($ismore && $i == $endcnt) { $links .= ' ' . _t('span', '&', array('class' => 'sep')) . ' '; } elseif ($i !== $cnt) { $links .= _t('span', $separator, array('class' => 'sep')) . ' '; } $i++; } } elseif (is_integer($index)) { $cats = $cats[$index]; $options['href'] = apply_filters('wpi_links_' . $section, get_category_link($cats->cat_ID)); $options['title'] = $cats->cat_name . ' (' . $cats->count . ' articles in this category)'; $links .= _t('a', $cats->name, $options); } unset($cats); if ($echo == 1) { echo $links; } else { return $links; } }
public function build() { global $wp_query; switch (is_at()) { case 'home': case 'front_page': $pathway = $this->getHome(); break; case 'single': $pathway = $this->getSingle(); break; case 'page': $pathway = $this->getPage(); break; case 'category': $pathway = $this->getCategory(); break; case 'tag': $pathway = $this->getTag(); break; case 'search': $pathway = $this->getSearch(); break; case wpiSection::YEAR: $pathway = $this->getDate(wpiSection::YEAR); break; case wpiSection::MONTH: $pathway = $this->getDate(wpiSection::MONTH); break; case wpiSection::DAY: $pathway = $this->getDate(wpiSection::DAY); break; case wpiSection::AUTHOR: $pathway = $this->getAuthor(); break; case wpiSection::PAGE404: $pathway = $this->getLost(); break; case wpiSection::ATTACHMENT: $pathway = $this->getAttachment(); break; } $htm = PHP_EOL; if (!has_count($pathway)) { return; } foreach ($pathway as $key => $value) { $att = $value[1]; $att['href'] = apply_filters(wpiFilter::FILTER_LINKS, $att['href']); if ($key == 'home') { $att['href'] = trailingslashit($att['href']); } // append tooltips class if there is title if (isset($att['title'])) { $att['class'] = $att['class'] . ' ttip'; } $links = _t('a', $value[0], $att); $htm .= stab(4) . _t('li', $links); /** * Add trailing slash on home url * correct status header * @bugs fixes 301 redirect * 6/27/2008 7:57:01 PM $ck */ if ($key != 'first' && $key != 'last') { $htm .= stab(4) . _t('li', _t('span', '›'), array('class' => 'sep')); } } unset($pathway); $htm = _t('ul', $htm . stab(3), array('class' => 'r cfl cf')); return $htm; }
function wpi_single_type_title() { $section = is_at(); $callback = 'single_' . $section . '_title'; $output = get_the_title(); switch ($section) { case 'day': $output = 'Archive for ' . get_the_time('F jS, Y'); break; case 'month': $output = 'Archive for ' . get_the_time('F, Y'); break; case 'year': $output = 'Archive for ' . get_the_time('Y'); break; } echo $output; }
function wpi_template_search() { global $post; $pby_class = wpi_get_theme_option('post_by_enable') ? 'pby' : 'pby dn'; ?> <ul class="r cf"> <?php while (have_posts()) { the_post(); ?> <li class="xfolkentry hentry hreview vevent cf prepend-1 append-1"> <dl class="r span-13"> <dd class="postmeta-date fl"> <ul class="span-1 pdate r"> <li class="date-month"><span><?php the_time('M'); ?> </span></li> <li class="date-day"><span><?php the_time('d'); ?> </span></li> <li class="Person ox"> <address class="rtxt ava <?php wpiGravatar::authorGID(); ?> depiction"> <span class="photo rtxt microid-Sha1sum"><?php author_microid(); ?> </span> </address> </li> </ul> </dd> <dd class="postmeta-head span-13 start fl"> <?php wpi_hatom_title(); ?> <div class="postmeta-info"> <span class="<?php echo $pby_class; ?> ">Posted by <cite class="vcard reviewer author"><?php wpi_post_author(); ?> </cite>.</span> <p class="di"><?php _e('Filed under', WPI_META); wpi_cat_links(1); ?> .</p> <p><span class="ptime r"><?php printf(__(' <cite>%s</cite>', WPI_META), wpi_get_postime()); ?> </span></p> </div> </dd> <?php $content_class = 'entry-content description entry cl ox'; ?> <?php // maybe rep summary for vevent if (!has_excerpt($post->ID)) { $content_class .= ' entry-summary summary'; } ?> <dd class="<?php echo $content_class; ?> "> <?php if (wpi_option('post_excerpt') && has_excerpt($post->ID)) { ?> <blockquote class="has-excerpt entry-summary summary span-4 fr" cite="<?php rawurlencode(get_permalink()); ?> "> <?php the_excerpt(); ?> </blockquote> <?php } ?> <?php do_action('wpi_before_content_' . is_at(), $post); ?> <?php the_content('<span>Read the rest of this entry</span>'); ?> </dd> <?php the_tags('<dd class="postmeta-tags"><acronym class="rtxt fl" title="Tags » Taxonomy">Tags:</acronym> <ul class="tags r cfl cf"><li>', '<span class="sep">,</span> </li><li>', '</li></ul></dd>'); ?> <?php $rating_class = wpi_option('post_hrating') ? 'rating-count' : 'rating-count dn'; ?> <dd class="postmeta-comments cf"> <ul class="xoxo cfl r cf"> <li class="<?php echo $rating_class; ?> "><?php wpi_hrating(); ?> </li> <li class="comments-link"> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> </li> </ul> </dd> <dd class="dn"> <ul class="more"> <li> <abbr class="dtstart published dtreviewed dc-date" title="<?php the_time('Y-m-dTH:i:s:Z'); ?> "><?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?> </abbr> </li> <li> <abbr class="dtend updated dtexpired" title="<?php the_modified_date('Y-m-dTH:i:s:Z'); ?> "><?php the_modified_date('F j, Y'); ?> at <?php the_modified_date('g:i a'); ?> </abbr> </li> <li class="version">0.3</li> <li class="type">url</li> </ul> </dd> </dl> <!-- <?php trackback_rdf(); ?> --> </li> <?php $cnt++; ?> <?php } ?> </ul> <?php }
/** * Wpi::__construct() * * @return */ public function __construct() { self::getFile(array('filters-enum', 'client', 'style', 'template', 'gravatar', 'sidebar'), 'class'); self::getFile(array('browscap', 'body_class'), 'import'); self::getFile(array('utils', 'formatting', 'filters', 'query', 'links', 'template', 'plugin', 'widgets', 'comments', 'author')); if (is_admin()) { add_action('admin_menu', array($this, 'setThemeOptions')); // post template form wpi_foreach_hook(array('simple_edit_form', 'edit_form_advanced', 'edit_page_form'), 'wpi_post_metaform'); wpi_foreach_hook(array('edit_post', 'publish_post', 'save_post', 'edit_page_form'), 'wpi_update_post_form'); // User profile form wpi_foreach_hook(array('profile_personal_options' => 'wpi_profile_options', 'personal_options_update' => 'wpi_profile_options_update')); } wpi_plugin_init(); wpi_default_filters(); // client browser $this->Browser = new Browscap(WPI_CACHE_DIR); if (is_object($this->Browser)) { $this->setBrowscapPref(); } // section $this->section = is_at(); // lost // scripts if ($this->Browser->JavaScript) { self::getFile('scripts', 'class'); $this->Script = new wpiScripts(); $js = array('jquery' => 'head', 'tooltip' => 'head', 'footer' => 'footer', 'css' => 'footer'); if (wpi_option('client_time_styles')) { $js['cookie'] = 'head'; $js['client-time'] = 'head'; } // default scripts library $this->registerScript($js); if (wpi_option('widget_treeview')) { $this->registerScript(array('treeview' => 'head', 'f-treeview' => 'footer')); } add_action('wp_head', array($this->Script, 'printHead'), 10); add_action('wp_head', array($this->Script, 'embedScript'), 10); add_action(wpiFilter::ACTION_FOOTER_SCRIPT, array($this->Script, 'printFooter'), 10); } // stylesheets if ($this->Browser->supportsCSS && !is_admin() && !is_feed()) { $this->Style = new wpiStyle(); $this->Style->client_css_version = $this->Browser->CssVersion; if (wpi_option('widget_treeview')) { $this->Style->register('image-treeview'); } if (is_active_widget('widget_flickrRSS')) { // load at active section $widget_id = 'flickrrss'; $active = wpi_widget_active_section($widget_id); foreach ($active as $k => $section) { $this->Style->register($widget_id, $section); } unset($active, $widget_id); } if (wpi_is_plugin_active('global-translator/translator.php')) { $tag = 'translator-image'; $this->Style->register($tag, wpiSection::SINGLE); $this->Style->register($tag, wpiSection::PAGE); $this->Style->register($tag, wpiSection::ATTACHMENT); } if (wpi_option('css_via_header')) { $this->Style->printStyles(); } else { add_action(wpiFilter::ACTION_META_LINK, array($this->Style, 'printStyles')); } } // sidebar $this->Sidebar = new wpiSidebar(); $this->Sidebar->setSidebar(); // custom header $this->Template = new wpiTemplate(); if (defined(WPI_DEBUG)) { add_action('wp_footer', array($this, 'debug')); } // self::debugDefaultFilters() }
public function embedScript() { global $wp_query; list($lang, $locale) = explode('-', get_bloginfo('language')); $pid = isset($wp_query->post->ID) ? $wp_query->post->ID : 0; $js = PHP_EOL . PHP_T; $js .= '/*<![CDATA[*/' . PHP_EOL . PHP_T . PHP_T; $js .= 'var wpi = {url:' . json_encode(WPI_URL_SLASHIT); $js .= ',id:' . json_encode(wpiTemplate::bodyID()); $js .= ',blogname:' . json_encode(WPI_BLOG_NAME); $js .= ',theme_url:' . json_encode(WPI_THEME_URL); $js .= ',section:' . json_encode(is_at()); $js .= ',permalink:' . json_encode(trailingslashit(self_uri())); $jspath = json_encode(rel(WPI_THEME_URL . 'public/scripts/')); $jsurl = json_encode(wpi_get_scripts_url('%s')); $js .= ',script:{path:' . $jspath . ',url:' . $jsurl . '}'; if (wpi_option('client_time_styles')) { $js .= ',pid:' . $pid . ',cl_type:td};jQuery(document).ready(function(){if( $(\'#\'+wpi.id).hasClass(wpi.cl_type) == false){ $(\'#\'+wpi.id).addClass(wpi.cl_type);jQuery.cookie(\'wpi-cl\',wpi.cl_type,{duration: 1/24,path: "/"});};});' . PHP_EOL; } else { $js .= ',pid:' . $pid . '};' . PHP_EOL; } // check client cookie; if ($wp_query->is_search || $wp_query->is_404) { // google webmaster 404 widget $js .= PHP_T . PHP_T . 'var GOOG_FIXURL_LANG = \'' . $lang . '\';var GOOG_FIXURL_SITE = wpi.url;' . PHP_EOL; } $js .= PHP_T . '/*]]>*/' . PHP_EOL . PHP_T; echo PHP_T; t('script', $js, array('id' => 'wp-js-head-embed', 'type' => 'text/javascript', 'defer' => 'defer', 'charset' => 'utf-8')); }
<?php if (function_exists('get_header')) { get_header(); } else { die(42); } $section = is_at(); if ($section == wpiSection::YEAR || $section == wpiSection::MONTH || $section == wpiSection::DAY || $section == wpiSection::AUTHOR || $section == wpiSection::PAGE404) { wpi_section_start('meta-title'); wpi_section_end(); } wpi_section_start('content-top'); ?> <div id="main"> <?php if (have_posts()) { wpi_current_template(); wpi_pagination(); ?> <?php } else { wpi_template_nopost(); ?> <?php } ?> </div> <?php
public function bannerIntenalCSS() { if (!self::bannerReady()) { return; } $sc = is_at(); $is_articles = $sc == wpiSection::SINGLE || $sc == wpiSection::PAGE ? true : false; $css = PHP_EOL; $burl = wpi_option('banner_url'); $height = wpi_option('banner_height'); $repeat = wpi_option('banner_repeat'); // global image url $burl = !empty($burl) ? $burl : 'http://static.animepaper.net/upload/rotate.jpg'; $height = !empty($height) ? $height : '72px'; $repeat = !empty($repeat) ? $repeat : 'no-repeat'; if ($is_articles) { if (($purl = wpi_get_postmeta('banner_url')) != false) { $burl = !empty($purl) ? $purl : $burl; } if (($pheight = wpi_get_postmeta('banner_height')) != false) { $height = !empty($pheight) ? $pheight : $height; } if (($prepeat = wpi_get_postmeta('banner_repeat')) != false) { $repeat = !empty($prepeat) ? $prepeat : $repeat; } } if ($sc == wpiSection::AUTHOR) { global $wp_query; $puser = $wp_query->queried_object; if (($url = $puser->user_banner_url) != false) { $burl = !empty($url) ? $url : $burl; } if (($uheight = $puser->user_banner_height) != false) { $height = !empty($uheight) ? $uheight : $height; } if (($urepeat = $puser->user_banner_repeat) != false) { $repeat = !empty($urepeat) ? $urepeat : $repeat; } unset($puser); } $css .= PHP_T . '#banner{background-color:#f9f9f9;background-image:url('; $css .= $burl . ');border-bottom:2px solid #ddd;'; $css .= 'border-top:1px solid #999;height:' . $height . ';'; $css .= 'background-position:0% 0%;background-repeat:' . $repeat; $css .= '}' . PHP_EOL; echo $css; }