Skip to content

Commit

Permalink
feat:add friend icon
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfa committed Apr 30, 2024
1 parent 25764f1 commit 58428ed
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 11 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ Farallon is a simple single column wordpress theme with perfect performace and e

[中文说明](https://github.com/bigfa/Farallon/blob/develop/README_CN.md)

latest version : `0.5.5`
latest version : `0.5.6`

[Simple User Guide(Chinese)](https://fatesinger.com/101971)

## Changelog

### 0.5.6

- add friend icon
- disable some filter in admin panel

### 0.5.5

- add github icon setting
Expand Down
7 changes: 6 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

![Wordpress 主题 Farallon](https://static.fatesinger.com/2023/06/u1ak8xgmyn9ec24r.png)

最新版本: `0.5.5`
最新版本: `0.5.6`

本主题禁止各种修改作者链接打包重新发布的行为。

[简单的使用文档](https://fatesinger.com/101971)

## 更新日志

### 0.5.6

- 增加友情链接标识
- 禁用一些钩子在后台生效

### 0.5.5

- 增加 Github 图标设置
Expand Down
2 changes: 1 addition & 1 deletion build/css/app.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/setting.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions js/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ document.querySelector('#pure-save')?.addEventListener('click', (event) => {
// @ts-ignore
const data = new URLSearchParams(formData);

const emailElement = document.querySelector('#pure-setting-email');
const email = emailElement?.getAttribute('value');
if (email && !isEmailValid(email)) {
return alert('Email is not valid');
}
// const emailElement = document.querySelector('#pure-setting-email');
// const email = emailElement?.getAttribute('value');
// if (email && !isEmailValid(email)) {
// return alert('Email is not valid');
// }

//@ts-ignore
jQuery.ajax({
Expand Down
27 changes: 26 additions & 1 deletion modules/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,37 @@ public function __construct()
{
global $farallonSetting;
add_action('rest_api_init', array($this, 'register_routes'));
if ($farallonSetting->get_setting('show_author'))
if ($farallonSetting->get_setting('show_author') && is_singular())
add_filter('get_comment_author', array($this, 'get_comment_author_hack'), 10, 3);
if ($farallonSetting->get_setting('show_parent'))
add_filter('get_comment_text', array($this, 'hack_get_comment_text'), 0, 2);
if ($farallonSetting->get_setting('disable_comment_link'))
add_filter('get_comment_author_link', array($this, 'get_comment_author_link_hack'), 10, 3);
if ($farallonSetting->get_setting('friend_icon') && !is_admin())
add_filter('get_comment_author', array($this, 'show_friend_icon'), 10, 3);
}

function is_friend($url = '')
{
if (empty($url)) {
return false;
}
$urls = get_bookmarks();
foreach ($urls as $bookmark) {
// check if the url is contained in the bookmark
if (strpos($bookmark->link_url, $url) !== false) {
return true;
}
}
}

function show_friend_icon($comment_author, $comment_id, $comment)
{
$comment_author_url = $comment->comment_author_url;
// get domain name
$comment_author_url = parse_url($comment_author_url, PHP_URL_HOST);

return $this->is_friend($comment_author_url) ? $comment_author . '<svg viewBox="0 0 64 64" fill="none" role="presentation" aria-hidden="true" focusable="false" class="friend--icon" title="Friend of author."><path fill-rule="evenodd" clip-rule="evenodd" d="M56.48 38.3C58.13 36.58 60 34.6 60 32c0-2.6-1.88-4.57-3.52-6.3-.95-.97-1.98-2.05-2.3-2.88-.33-.82-.35-2.17-.38-3.49-.02-2.43-.07-5.2-2-7.13-1.92-1.92-4.7-1.97-7.13-2h-.43c-1.17-.02-2.29-.04-3.07-.38-.87-.37-1.9-1.35-2.87-2.3C36.58 5.89 34.6 4 32 4c-2.6 0-4.57 1.88-6.3 3.53-.97.94-2.05 1.97-2.88 2.3-.82.32-2.17.34-3.49.37-2.43.03-5.2.08-7.13 2-1.92 1.93-1.97 4.7-2 7.13v.43c-.02 1.17-.04 2.29-.38 3.06-.37.88-1.35 1.9-2.3 2.88C5.89 27.43 4 29.4 4 32c0 2.6 1.88 4.58 3.53 6.3.94.98 1.97 2.05 2.3 2.88.32.82.34 2.17.37 3.49.03 2.43.08 5.2 2 7.13 1.93 1.93 4.7 1.98 7.13 2h.43c1.17.02 2.29.04 3.06.38.88.37 1.9 1.34 2.88 2.3C27.43 58.13 29.4 60 32 60c2.6 0 4.58-1.88 6.3-3.52.98-.95 2.05-1.98 2.88-2.3.82-.33 2.17-.35 3.49-.38 2.43-.02 5.2-.07 7.13-2 1.93-1.92 1.98-4.7 2-7.13v-.43c.02-1.17.04-2.29.38-3.07.37-.87 1.34-1.9 2.3-2.87zM33.1 45.15c-.66.47-1.55.47-2.22 0C27.57 42.8 18 35.76 18 28.9c0-6.85 6.5-10.25 13.26-4.45.43.37 1.05.37 1.48 0 6.76-5.8 13.27-2.4 13.26 4.45 0 6.56-9.57 13.9-12.89 16.24z" fill="#FFC017"></path></svg>' : $comment_author;
}

function get_comment_author_link_hack($comment_author_link, $comment_author, $comment_id)
Expand Down
6 changes: 6 additions & 0 deletions modules/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@ function setting_switch($params)
'label' => __('No reply text', 'Farallon'),
'description' => __('Text display when no comment in current post.', 'Farallon')
],
[
'type' => 'switch',
'name' => 'friend_icon',
'label' => __('Friend icon', 'Farallon'),
'description' => __('Show icon when comment author url is in blogroll.', 'Farallon')
],
]
],
[
Expand Down
11 changes: 11 additions & 0 deletions scss/modules/comment.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@
flex: 1 1 auto;
display: flex;
align-items: center;
.url {
display: flex;
align-items: center;
}
.friend--icon {
margin-left: 5px;

// fill: var(--farallon-main-color);
width: 16px;
height: 16px;
}
&__tip {
margin-left: 5px;
font-size: 12px;
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Theme URI: https://github.com/bigfa/Farallon
Author: bigfa
Author URI: https://github.com/bigfa
Description: theme 2024
Version: 0.5.5
Version: 0.5.6
Tags: Minimalism, Responsive
*/

0 comments on commit 58428ed

Please sign in to comment.