Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Commit

Permalink
fix(search): fix avatar.
Browse files Browse the repository at this point in the history
fix(sidebar): fix sidebar pic.
feature(index): add random article featured picture.
feature(options): add setting of set how many articles are shown on index.
docs: update README.
  • Loading branch information
TigerBeanst committed May 18, 2018
1 parent 37a0512 commit 93bcf84
Show file tree
Hide file tree
Showing 29 changed files with 38 additions and 20 deletions.
17 changes: 17 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ function my_enqueue_scripts() {
}
add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts', 1 );

//加速 Gravatar 头像
function replace_gravatar($avatar) {
$avatar = str_replace(array("//gravatar.com/", "//secure.gravatar.com/", "//www.gravatar.com/", "//0.gravatar.com/", "//1.gravatar.com/", "//2.gravatar.com/", "//cn.gravatar.com/"), "//cdn.v2ex.com/gr", $avatar);
return $avatar;
}
add_filter( 'get_avatar', 'replace_gravatar' );

//来自知更鸟的评论带图
add_action('comment_text', 'comments_embed_img', 2);
function comments_embed_img($comment) {
Expand Down Expand Up @@ -168,4 +175,14 @@ function mail_smtp( $phpmailer ) {
$phpmailer->IsSMTP();
}

//修改每页显示的文章数
function custom_posts_per_page($query){
if(is_home()){
$query->set('posts_per_page',get_RnMaterial('posts_num','5'));//首页每页显示8篇文章
}
if(is_search()){
$query->set('posts_per_page',-1);//搜索页显示所有匹配的文章,不分页
}
}
add_action('pre_get_posts','custom_posts_per_page');
?>
Binary file added img/random/material-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/random/material-9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/sidebar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 5 additions & 13 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php get_header(); ?>
<?php $count_posts = wp_count_posts(); $published_posts = $count_posts->publish;?>
<?php $post_nn = get_RnMaterial("posts_num","5"); ?>
<body id="scheme-Paradox" class="lazy">
<div class="material-layout mdl-js-layout has-drawer is-upgraded">
<main class="material-layout__content" id="main">
Expand Down Expand Up @@ -61,7 +63,7 @@

<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post_entry-module mdl-card mdl-shadow--2dp mdl-cell mdl-cell--12-col fade out">
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50 lazy" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");echo $img_src[0]; ?>)">
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50 lazy" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");if($img_src){echo $img_src[0];}else{$rann=rand(1,19);echo get_bloginfo('template_url').'/img/random/material-'.$rann.'.png';}; ?>)">
<p class="article-headline-p">
<a href="<?php the_permalink();?>"><?php the_title();?></a></p>
</div>
Expand All @@ -84,22 +86,12 @@
<?php endwhile; ?>
<?php endif; ?>

<?php if($published_posts>$post_nn){ ?>
<nav class="nav-body">
<div class="nav-next"><?php next_posts_link(__('<i class="material-icons sidebar-material-icons">navigate_before</i>')) ?></div>
<div class="nav-prev"><?php previous_posts_link(__('<i class="material-icons sidebar-material-icons">navigate_next</i>')) ?></div>
</nav>
<script type="text/ls-javascript" id="thumbnail-script">var randomNum;

var locatePost = $('.locate-thumbnail-symbol').next();
for (var i = 0; i < 5; i++) {
randomNum = Math.floor(Math.random() * 19 + 1);

locatePost.children('.post_thumbnail-random').attr('id', 'random_thumbnail-' + randomNum);
locatePost.children('.post_thumbnail-random').attr('data-original', 'https://materialcdn.b0.upaiyun.com/img/random/material-' + randomNum + '.png');
$('.post_thumbnail-random').addClass('lazy');

locatePost = locatePost.next();
}</script>
<?php }; ?>
</div>
<?php get_template_part( 'nav', 'index' ); ?>
</div>
Expand Down
9 changes: 9 additions & 0 deletions options.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ function optionsframework_options() {
'type' => 'heading'
);

$options[] = array(
'name' => __( '首页显示文章数', 'theme-textdomain' ),
'desc' => __( '请输入整数,不要留空,留空时<b>默认为 5</b>', 'theme-textdomain' ),
'id' => 'posts_num',
'std' => '5',
'class' => 'mini',
'type' => 'text'
);

$options[] = array(
'name' => __( '背景颜色', 'theme-textdomain' ),
'desc' => __( '请输入 RGB 值,不要留空,留空时背景纯白。<b>默认为 #dedede</b>', 'theme-textdomain' ),
Expand Down
2 changes: 1 addition & 1 deletion page.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="material-post mdl-grid">
<div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");echo $img_src[0]; ?>)">
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");if($img_src){echo $img_src[0];}else{$rann=rand(1,19);echo get_bloginfo('template_url').'/img/random/material-'.$rann.'.png';}; ?>)">
<p class="article-headline-p"><?php the_title();?></p></div>
<div class="mdl-color-text--grey-700 mdl-card__supporting-text meta">
<div id="author-avatar">
Expand Down
2 changes: 1 addition & 1 deletion pages/page-archieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="material-post mdl-grid">
<div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");echo $img_src[0]; ?>)">
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");if($img_src){echo $img_src[0];}else{$rann=rand(1,19);echo get_bloginfo('template_url').'/img/random/material-'.$rann.'.png';}; ?>)">
<p class="article-headline-p"><?php the_title();?></p></div>
<div class="mdl-color-text--grey-700 mdl-card__supporting-text meta">
<div id="author-avatar">
Expand Down
2 changes: 1 addition & 1 deletion pages/page-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="material-post mdl-grid">
<div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");echo $img_src[0]; ?>)">
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");if($img_src){echo $img_src[0];}else{$rann=rand(1,19);echo get_bloginfo('template_url').'/img/random/material-'.$rann.'.png';}; ?>)">
<p class="article-headline-p"><?php the_title();?></p></div>
<div class="mdl-color-text--grey-700 mdl-card__supporting-text meta">
<div id="author-avatar">
Expand Down
2 changes: 1 addition & 1 deletion search.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div id="post_entry-info">
<div id="post_entry-left-info" class="mdl-card__supporting-text meta mdl-color-text--grey-600">
<div id="author-avatar">
<img src="<?php echo bloginfo('template_url');?>/img/avatar.png" width="44px" height="44px" alt="neoFelhz's avatar"></div>
<?php echo get_avatar(1,32,avatar); ?></div>
<div>
<strong><?php the_author(); ?></strong>
<span><?php the_time('M d, Y')?></span></div>
Expand Down
2 changes: 1 addition & 1 deletion single.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="material-post mdl-grid">
<div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--12-col">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");echo $img_src[0]; ?>)">
<div class="post_thumbnail-custom mdl-card__media mdl-color-text--grey-50" style="background-image:url(<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");if($img_src){echo $img_src[0];}else{$rann=rand(1,19);echo get_bloginfo('template_url').'/img/random/material-'.$rann.'.png';}; ?>)">
<p class="article-headline-p"><?php the_title();?></p></div>
<div class="mdl-color-text--grey-700 mdl-card__supporting-text meta">
<div id="author-avatar">
Expand Down
4 changes: 2 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
Theme Name: RnMaterial
Theme URI: https://jakting.com
Theme URI: https://github.com/hjthjthjt/rnmaterial
Author: Jartip Hwang
Author URI: https://jakting.com
Description: Maybe it is the best Material Design WordPress Theme. This Theme is Migrated from hexo-theme-material(https://github.com/viosey/hexo-theme-material)
Version: 2.0
Version: 2.0.1
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: white, light, one-column, material
Expand Down

0 comments on commit 93bcf84

Please sign in to comment.