Skip to content

Commit

Permalink
升级至V3版本
Browse files Browse the repository at this point in the history
  • Loading branch information
xenice committed Jun 24, 2022
1 parent de5f102 commit 36f258e
Show file tree
Hide file tree
Showing 144 changed files with 8,774 additions and 1,861 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# onenice
> OneNice是一款超级简洁的WordPress主题,支持中英文,免费开源,无任何加密,无任何冗余代码,无任何授权限制,可随便使用。**下载最新版本请进技术交流QQ群707252643**,作者QQ942835420。
> OneNice是一款超级简洁的WordPress主题,支持中英文,免费开源,无任何加密,无任何冗余代码,无任何授权限制,可随便使用。技术交流QQ群707252643,作者QQ942835420
### 主题演示

Expand Down Expand Up @@ -40,7 +40,22 @@ MVC分层架构,层次分明,扩展更灵活、维护更方便;

### 更新说明

**最后更新:2021.02.28**
**最后更新:2022.06.24**

v3.0.0
- 新增第三方登录功能
- 新增点赞功能
- 新增页面动态果
- 新增首页置顶文章
- 兼容elementor插件
- 美化页面
- 更换菜单风格
- 优化核心代码
- 调整后台设置页面;

v2.1.9
- 修改头像被墙问题;
- 增加归档页面;

v2.1.8
- 修复若干BUG;
Expand Down Expand Up @@ -82,4 +97,4 @@ v2.0.3
- 修复评论列表楼层序号反向问题;
- 添加缩略图alt属性和链接标签;
- 添加放灯片图片alt属性;
- 修复标签页面不显示文章问题;
- 修复标签页面不显示文章问题;
52 changes: 52 additions & 0 deletions app/pro/Loader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
namespace app\pro;

use xenice\theme\Theme;

class Loader extends \app\web\Loader
{
public function __construct()
{
Theme::set('default_theme', 'web');

$aliases = [
'article' => 'app\pro\model\Article',
'article_pointer' => 'app\pro\model\pointer\Article',
'template' => 'app\pro\template\Template',
];

$prepares = [
11 => 'xenice\login\Login',
60 => 'app\pro\ajax\Ajax',
];

if(is_admin()){
//Theme::bind('xenice_options_init', [$this,'set']);
$prepares[90] = 'app\pro\module\inner\Admin';
}
else{
$prepares[100] = 'app\pro\module\inner\Guest';
}

$args = [
'aliases' => $aliases,
'prepares' => $prepares,
];

parent::__construct($args);
}

/*
public function set($options)
{
$options = parent::set($options);
$options[0]['fields'][0]['value'] = '#FF5E52 #FF5E52 #FF5E52 #f13c2f #fff #fc938b';
$options[0]['fields'][2]['value'] = STATIC_URL_EX . '/images/logo.png';
$options[1]['fields'][3]['value'][0]['src'] = STATIC_URL_EX . '/images/onenice-1.jpg';
$options[1]['fields'][3]['value'][1]['src'] = STATIC_URL_EX . '/images/onenice-2.jpg';
$options[1]['fields'][3]['value'][2]['src'] = STATIC_URL_EX . '/images/onenice-3.jpg';
return array_merge($options, require(__DIR__ . '/options.php'));
}*/
}
12 changes: 12 additions & 0 deletions app/pro/ajax/Ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace app\pro\ajax;


class Ajax extends \app\web\ajax\Ajax
{
public function __construct()
{
parent::__construct();
LikeAjax::instance();
}
}
40 changes: 40 additions & 0 deletions app/pro/ajax/LikeAjax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
namespace app\pro\ajax;

use xenice\theme\Theme;
use xenice\theme\Ajax;

class LikeAjax extends Ajax
{
public function __construct()
{
$this->action('like');
}

public function like()
{
$id = esc_sql($_POST['pid']);
if(isset($_COOKIE['xenice_like_'.$id])){
echo json_encode(['key'=>'liked', 'value'=>_t('You already liked it')]);
exit;
}

$count = get_post_meta($id, 'likes', true);
if($count){
$count ++;
update_post_meta($id, 'likes', $count);
}
else{
$count = 1;
add_post_meta($id, 'likes', $count, true);
}

$html = '<i class="fa fa-thumbs-o-up"></i>&nbsp;' . _t('Liked') . '(<span>' .$count . '</span>)';
echo json_encode(['key'=>'success','value'=>$html]);

$expire = time() + 99999999;
$domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; // make cookies work with localhost
setcookie('xenice_like_'.$id, $id, $expire, '/', $domain);
exit;
}
}
15 changes: 15 additions & 0 deletions app/pro/controller/CategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace app\pro\controller;

use xenice\theme\Theme;

class CategoryController extends \app\web\controller\CategoryController
{

public function index($view = 'index')
{
parent::index($view);
}

}
122 changes: 122 additions & 0 deletions app/pro/controller/SingleController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

namespace app\pro\controller;

use xenice\theme\Theme;

class SingleController extends \app\web\controller\SingleController
{
public function index($view = 'index')
{
$this->addScripts();
parent::index($view);
}

public function scripts()
{
parent::scripts();

$cdn = take('enable_cdn');
$cdn_url = take('cdn_url');

if(take('enable_photoswipe')){
if($cdn){
wp_enqueue_style('photoswipe-css', $cdn_url . '/photoswipe/4.1.0/photoswipe.min.css', [], '4.1.0');
wp_enqueue_style('photoswipe-css-skin', $cdn_url . '/photoswipe/4.1.0/default-skin/default-skin.min.css', [], '4.1.0');
wp_enqueue_script('photoswipe-js', $cdn_url . '/photoswipe/4.1.0/photoswipe.min.js', [], '4.1.0', true);
wp_enqueue_script('photoswipe-js-ui', $cdn_url . '/photoswipe/4.1.0/photoswipe-ui-default.min.js', [], '4.1.0', true);
}
else{
wp_enqueue_style('photoswipe-css', STATIC_URL_EX . '/lib/photoswipe/css/photoswipe.css', [], '4.1.0');
wp_enqueue_style('photoswipe-css-skin', STATIC_URL_EX . '/lib/photoswipe/css/default-skin/default-skin.css', [], '4.1.0');
wp_enqueue_script('photoswipe-js', STATIC_URL_EX . '/lib/photoswipe/js/photoswipe.min.js', [], '4.1.0', true);
wp_enqueue_script('photoswipe-js-ui', STATIC_URL_EX . '/lib/photoswipe/js/photoswipe-ui-default.min.js', [], '4.1.0', true);
}
wp_enqueue_script('photoswipe-init', STATIC_URL_EX . '/lib/photoswipe/init.js', [], '4.1.0', true);
}


}

private function addScripts()
{
if(take('enable_photoswipe')){
Theme::use('template')->js .=<<<js
jQuery(function($){
var imgdefereds=[];
$('.gallery img').each(function(){
var dfd=$.Deferred();
$(this).bind('load',function(){
dfd.resolve();
}).bind('error',function(){
// dfd.resolve();
});
if(this.complete){
setTimeout(function(){
dfd.resolve();
},1000);
}
else{
imgdefereds.push(dfd);
}
});
$.when.apply(null,imgdefereds).done(function(){
$('.gallery img').each(function(i, val){
var img = new Image();
img.src = this.src;
let obj = {}
// 如果图片被缓存,则直接返回缓存数据
if (img.complete) {
obj.width = img.width;
obj.height = img.height;
} else {
img.onload = function () {
obj.width = img.width;
obj.height = img.height;
}
}
var str = '';
str += '<figure><a href="'+this.src+'" data-size="'+obj.width+'x'+obj.height+'">';
str += '<img src="'+this.src+'" alt="'+this.alt+'" title="'+this.title+'" />';
str +='</a></figure>';
$(this).replaceWith(str);
});
initPhotoSwipeFromDOM('.gallery');
});
});
js;
}

if(take('enable_like')){
Theme::use('template')->js .=<<<js
jQuery(function($){
$('.post-like-a').on('click', function(){
var pid = $(this).attr('data-pid');
var nonce = $(this).attr('data-nonce');
$.post(
xenice.action + 'like',
{
like_nonce: nonce,
pid: pid,
},
function (data) {
var data = JSON.parse(data)
if(data.key == 'success'){
$('.post-like-a').html(data.value);
}
else if(data.key == 'liked'){
alert(data.value);
}
else{
console.log(data);
}
}
);
})
});
js;
}


}
}
16 changes: 16 additions & 0 deletions app/pro/model/Article.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace app\pro\model;

use xenice\theme\Theme;

class Article extends \app\web\model\Article
{
public function __construct()
{
parent::__construct();

}


}
75 changes: 75 additions & 0 deletions app/pro/model/pointer/Article.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace app\pro\model\pointer;

use xenice\theme\Theme;

class Article extends \app\web\model\pointer\Article
{
private $shotcodes = [];

public function __construct($mix)
{
parent::__construct($mix);
}

/*
public function shortcode($tagname = 'data')
{
if(isset($this->shotcodes[$tagname])){
return $this->shotcodes[$tagname];
}
$shortcode = [];
$pattern = get_shortcode_regex([$tagname]);
if (preg_match_all( '/'. $pattern .'/s', $this->row('post_content'), $matches) && array_key_exists(2, $matches)){
$shortcode['code'] = $matches[0][0];
$shortcode['atts'] = shortcode_parse_atts($matches[0][0]);
unset($shortcode['atts'][0]);
unset($shortcode['atts'][1]);
$shortcode['value'] = $matches[5][0];
$this->shotcodes[$tagname] = $shortcode;
return $shortcode;
}
}
public function atts($name, $tagname = 'data')
{
if(isset($this->shotcodes[$tagname]['atts'][$name])){
return $this->shotcodes[$tagname]['atts'][$name];
}
if(isset($this->shotcodes[$tagname])){ // already execute
return;
}
$shortcode = $this->shortcode($tagname);
return $shortcode['atts'][$name]??null;
}
public function thumbnail($type = 'full')
{
if(empty($this->atts('image'))){
return parent::thumbnail($type);
}
else{
return $this->atts('image');
}
}
public function price()
{
if(empty($this->atts('price'))){
return _t('Free');
}
else{
return '¥' . $this->atts('price');
}
}
public function cnt($tags = ['data'])
{
$content = $this->content();
$pattern = get_shortcode_regex($tags);
//$pattern = '\[(\[?)([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
$content = preg_replace("/$pattern/", '', $content);
return $content;
}*/
}
Loading

0 comments on commit 36f258e

Please sign in to comment.