1 Star 0 Fork 1

unissn7 / Landscape Plus

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
functions.php 4.01 KB
一键复制 编辑 原始数据 按行查看 历史
unissn7 提交于 2014-10-06 11:21 . First Commit
<?php
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
add_action( 'optionsframework_custom_scripts', 'optionsframework_custom_scripts' );
function optionsframework_custom_scripts() { ?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#example_showhidden').click(function() {
jQuery('#section-example_text_hidden').fadeToggle(400);
});
if (jQuery('#example_showhidden:checked').val() !== undefined) {
jQuery('#section-example_text_hidden').show();
}
});
</script>
<?php
}
register_nav_menus(
array(
'main-nav' => __( '顶部导航' )
)
);
//Remove Useless WordPress Nav Classes
add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);
add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1);
add_filter('page_css_class', 'my_css_attributes_filter', 100, 1);
function my_css_attributes_filter($var) {
return is_array($var) ? array() : '';
}
function kr_get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
$terms = get_the_terms( $id, $taxonomy );
if ( is_wp_error( $terms ) )
return $terms;
if ( empty( $terms ) )
return false;
foreach ( $terms as $term ) {
$link = get_term_link( $term, $taxonomy );
if ( is_wp_error( $link ) )
return $link;
$term_links[] = '<li class="article-tag-list-item"><a href="' . esc_url( $link ) . '" class="article-tag-list-link" target="_blank">' . $term->name . '</a></li>';
}
$term_links = apply_filters( "term_links-$taxonomy", $term_links );
return $before . join( $sep, $term_links ) . $after;
}
function kr_the_tag_list($id = 0,$before = '', $sep = '', $after = '') {
echo apply_filters( 'kr_the_tag_list', kr_get_the_term_list( $id, 'post_tag', $before, $sep, $after ), $before, $sep, $after, $id );
}
function pagination($query_string) {
global $posts_per_page, $paged;
$my_query = new WP_Query($query_string . "&posts_per_page=-1");
$total_posts = $my_query->post_count;
if (empty($paged)) $paged = 1;
$prev = $paged - 1;
$next = $paged + 1;
$range = 2; // only edit this if you want to show more page-links
$showitems = ($range * 2) + 1;
$pages = ceil($total_posts / $posts_per_page);
if (1 != $pages) {
echo "<nav id='page-nav'>";
echo ($paged > 1 && $showitems < $pages) ? "
<a class='extend prev' rel='prev' href='" . get_pagenum_link($prev) . "'>« Prev</a>" : "";
for ($i = 1; $i <= $pages; $i++) {
if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems)) {
echo ($paged == $i) ? "<span class='page-number current'>" . $i . "</span>" : "<a class='page-number' href='" . get_pagenum_link($i) . "' >" . $i . "</a>";
}
}
echo ($paged < $pages && $showitems < $pages) ? "<a class='extend next' rel='next' href='" . get_pagenum_link($next) . "'>Next »</a>" : "";
echo "</nav>";
}
}
if( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => '底部小工具',
'before_widget' => '<div class="widget-wrap">', // widget 的开始标签
'after_widget' => '</div>', // widget 的结束标签
'before_title' => '<h3 class="widget-title">', // 标题的开始标签
'after_title' => '</h3>' // 标题的结束标签
));
}
//主题安装多说提示
add_action('admin_notices', 'showAdminMessages');
function showAdminMessages()
{
$plugin_messages = array();
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if(!is_plugin_active( 'duoshuo/duoshuo.php' ))
{
$plugin_messages[] = 'Landscape Plus 主题需要<a href="http://wordpress.org/plugins/duoshuo/">多说</a>或其它第三方评论系统支持。';
}
if(count($plugin_messages) > 0)
{
echo '
<div id="message" class="error">';
foreach($plugin_messages as $message)
{
echo '
<p>'.$message.'</p>
';
}
echo '</div>
';
}
}
PHP
1
https://gitee.com/pcdotfan/Landscape-Plus.git
git@gitee.com:pcdotfan/Landscape-Plus.git
pcdotfan
Landscape-Plus
Landscape Plus
master

搜索帮助