diff --git a/404.php b/404.php index 68dbf1bb..5c4999e9 100644 --- a/404.php +++ b/404.php @@ -39,7 +39,7 @@ - + diff --git a/README.md b/README.md index 47149a93..32ef824e 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ - 本主题**基于 [Sakura V3 Series](https://github.com/mashirozx/sakura/tree/3.x) 主题进行重构开发**,使用 [GPL V2.0](https://github.com/mirai-mamori/Sakurairo/blob/master/LICENSE) 协议开源。 -- 本主题使用了部分来自互联网的特效。由于版权及开源协议不明,无法具体说明相关信息。如果本主题使用到您制作的特效,烦请您通过邮件(me#okaeri.org)来取得联系。 +- 本主题使用了部分来自互联网的特效。由于版权及开源协议不明,无法具体说明相关信息。如果本主题使用到您制作的特效,烦请您通过邮件(me#hareru.org)来取得联系。 ### 引用相关: diff --git a/README_en.md b/README_en.md index 5810d521..8cfe719c 100644 --- a/README_en.md +++ b/README_en.md @@ -45,7 +45,7 @@ Please fill in with the issue template. Thanks for your cooperation. - The theme is **developed based on theme [Sakura](https://github.com/mashirozx/Sakura)**, licensed with [GPL V2.0](https://github.com/mirai-mamori/Sakurairo/blob/master/LICENSE). -- The theme uses some special effects from the Internet. Due to the unclear copyright information and open source lincenses, the related information cannot be dispalyed here. If the theme have used the special effects provided by you, please contant **me#okaeri.org** via email. +- The theme uses some special effects from the Internet. Due to the unclear copyright information and open source lincenses, the related information cannot be dispalyed here. If the theme have used the special effects provided by you, please contant **me#hareru.org** via email. ### References: diff --git a/README_ja.md b/README_ja.md index f56d440d..4b578dae 100644 --- a/README_ja.md +++ b/README_ja.md @@ -44,7 +44,7 @@ - 本テーマは、**[Sakura V3 Series](https://github.com/mashirozx/sakura/tree/3.x) テーマのリファクタリングに基づいており**、[GPL V2.0](https://github.com/mirai-mamori/Sakurairo/blob/master/LICENSE) でオープンソースとなっています -- このテーマの一部のエフェクトには、インターネットで公開されているエフェクトが使用されています。著作権やオープンソースの契約が不明なため、関連情報を明記することはできません。本テーマは貴方が作成されたエフェクトが使用されている場合は、メール(me#okaeri.org)でご連絡ください。メールアドレスは、送信前に“#”を@に変更ください。 +- このテーマの一部のエフェクトには、インターネットで公開されているエフェクトが使用されています。著作権やオープンソースの契約が不明なため、関連情報を明記することはできません。本テーマは貴方が作成されたエフェクトが使用されている場合は、メール(me#hareru.org)でご連絡ください。メールアドレスは、送信前に“#”を@に変更ください。 ### 参考資料: diff --git a/README_tw.md b/README_tw.md index 61b50499..853c2d83 100644 --- a/README_tw.md +++ b/README_tw.md @@ -49,7 +49,7 @@ - 本主題**基於 [Sakura V3 Series](https://github.com/mashirozx/sakura/tree/3.x) 主題進行重構開發**,使用 [GPL V2.0](https://github.com/mirai-mamori/Sakurairo/blob/master/LICENSE) 協議開源。 -- 本主題使用了部分來自網路的特效。由於版權及開源協議不明,無法具體說明相關資訊。如果本主題使用到您製作的特效,煩請您通過郵件(me#okaeri.org)來取得聯絡。 +- 本主題使用了部分來自網路的特效。由於版權及開源協議不明,無法具體說明相關資訊。如果本主題使用到您製作的特效,煩請您通過郵件(me#hareru.org)來取得聯絡。 ### 引用相關: diff --git a/archive.php b/archive.php index da920192..ddb2d4e3 100644 --- a/archive.php +++ b/archive.php @@ -39,14 +39,7 @@ endwhile; } */ // TODO: 'image_category'功能待实现 - $i = 0; while (have_posts()) : the_post(); - $article_class = ''; - if ($i == 1) { - $article_class = ' post-list-show'; - } else { - $i++; - } get_template_part('tpl/content', 'thumbcard'); endwhile; ?>
diff --git a/author.php b/author.php index aa670a5c..0d0f9acf 100644 --- a/author.php +++ b/author.php @@ -4,7 +4,7 @@ ?>
-
+
diff --git a/footer.php b/footer.php index e455eaad..08e8bf47 100644 --- a/footer.php +++ b/footer.php @@ -164,7 +164,10 @@ - + + diff --git a/functions.php b/functions.php index 04c2e99b..7790e2d4 100644 --- a/functions.php +++ b/functions.php @@ -12,7 +12,7 @@ define('IRO_VERSION', wp_get_theme()->get('Version')); -define('INT_VERSION', '19.0.0'); +define('INT_VERSION', '19.1.0'); define('BUILD_VERSION', '2'); function check_php_version($preset_version) @@ -162,15 +162,7 @@ function akina_setup() remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'start_post_rel_link', 10); remove_action('wp_head', 'wp_generator'); - remove_action('wp_head', 'wp_generator'); //隐藏wordpress版本 - remove_filter('the_content', 'wptexturize'); //取消标点符号转义 - - //remove_action('rest_api_init', 'wp_oembed_register_route'); - //remove_filter('rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4); - //remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10); - //remove_filter('oembed_response_data', 'get_oembed_response_data_rich', 10, 4); - //remove_action('wp_head', 'wp_oembed_add_discovery_links'); - //remove_action('wp_head', 'wp_oembed_add_host_js'); + remove_filter('the_content', 'wptexturize'); remove_action('template_redirect', 'rest_output_link_header', 11); function coolwp_remove_open_sans_from_wp_core() @@ -228,48 +220,179 @@ function my_css_attributes_filter($var) ; add_action('after_setup_theme', 'akina_setup'); -//说说页面 -function shuoshuo_custom_init() -{ +function register_shuoshuo_post_type() { $labels = array( - 'name' => __("Ideas", "sakurairo"), - 'singular_name' => __("Idea", "sakurairo"), - 'add_new' => __("Publish New Idea", "sakurairo"), - 'add_new_item' => __("Publish New Idea", "sakurairo"), - 'edit_item' => __("Edit Idea", "sakurairo"), - 'new_item' => __("New Idea", "sakurairo"), - 'view_item' => __("View Idea", "sakurairo"), - 'search_items' => __("Search Idea", "sakurairo"), - 'not_found' => __("Not Found Idea", "sakurairo"), - 'not_found_in_trash' => __("No Idea in the Trash", "sakurairo"), - 'parent_item_colon' => '', - 'menu_name' => __("Ideas", "sakurairo") + 'name' => _x('Shuoshuo', 'post type general name', 'sakurairo'), + 'singular_name' => _x('Shuoshuo', 'post type singular name', 'sakurairo'), + 'menu_name' => _x('Shuoshuo', 'admin menu', 'sakurairo'), + 'name_admin_bar' => _x('Shuoshuo', 'add new on admin bar', 'sakurairo'), + 'add_new' => _x('Add New', 'shuoshuo', 'sakurairo'), + 'add_new_item' => __('Add New Shuoshuo', 'sakurairo'), + 'new_item' => __('New Shuoshuo', 'sakurairo'), + 'edit_item' => __('Edit Shuoshuo', 'sakurairo'), + 'view_item' => __('View Shuoshuo', 'sakurairo'), + 'all_items' => __('All Shuoshuo', 'sakurairo'), + 'search_items' => __('Search Shuoshuo', 'sakurairo'), + 'parent_item_colon' => __('Parent Shuoshuo:', 'sakurairo'), + 'not_found' => __('No shuoshuo found.', 'sakurairo'), + 'not_found_in_trash' => __('No shuoshuo found in Trash.', 'sakurairo') ); + $args = array( - 'labels' => $labels, - 'public' => true, + 'labels' => $labels, + 'public' => true, 'publicly_queryable' => true, - 'show_ui' => true, - 'show_in_menu' => true, - 'show_in_rest' => true, - 'query_var' => true, - 'rewrite' => true, - 'capability_type' => 'post', - 'has_archive' => true, - 'hierarchical' => false, - 'menu_position' => null, - 'supports' => array( - 'title', - 'editor', - 'comments', - 'thumbnail', - 'author', - 'custom-fields' // Added support for custom fields - ) + 'show_ui' => true, + 'show_in_menu' => true, + 'show_in_rest' => true, + 'query_var' => true, + 'rewrite' => array('slug' => 'shuoshuo'), + 'capability_type' => 'post', + 'has_archive' => true, + 'hierarchical' => false, + 'menu_position' => null, + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'custom-fields', 'comments'), + 'taxonomies' => array('category') ); + register_post_type('shuoshuo', $args); } -add_action('init', 'shuoshuo_custom_init'); +add_action('init', 'register_shuoshuo_post_type'); + +function register_emotion_meta_boxes() { + register_meta('post', 'emotion', array( + 'show_in_rest' => true, + 'single' => true, + 'type' => 'string', + 'auth_callback' => function() { + return current_user_can('edit_posts'); + } + )); + register_meta('post', 'emotion_color', array( + 'show_in_rest' => true, + 'single' => true, + 'type' => 'string', + 'auth_callback' => function() { + return current_user_can('edit_posts'); + } + )); +} +add_action('init', 'register_emotion_meta_boxes'); + +function add_emotion_meta_box() { + add_meta_box( + 'emotion_meta_box_id', + __('Emotion Meta Box', 'sakurairo'), + 'render_emotion_meta_box', + 'shuoshuo', // 仅在shuoshuo内容类型中显示 + 'side', + 'default' + ); +} +add_action('add_meta_boxes', 'add_emotion_meta_box'); + +function render_emotion_meta_box($post) { + $emotion_value = get_post_meta($post->ID, 'emotion', true); + $emotion_color_value = get_post_meta($post->ID, 'emotion_color', true); + wp_nonce_field('emotion_meta_box_nonce', 'emotion_meta_box_nonce_field'); + echo ''; + echo ''; + echo '

'; + echo ''; + echo ''; + echo '

'; + echo '

' . __('For the Emotion, please fill in the Unicode value of the Fontawesome icon, and for the Emotion Color, please fill in the RGBA or hexadecimal color.', 'sakurairo') . '

'; +} + +function save_emotion_meta_box($post_id) { + if (!isset($_POST['emotion_meta_box_nonce_field']) || !wp_verify_nonce($_POST['emotion_meta_box_nonce_field'], 'emotion_meta_box_nonce')) { + return; + } + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { + return; + } + if (!current_user_can('edit_post', $post_id)) { + return; + } + if (isset($_POST['emotion'])) { + update_post_meta($post_id, 'emotion', sanitize_text_field($_POST['emotion'])); + } + if (isset($_POST['emotion_color'])) { + update_post_meta($post_id, 'emotion_color', sanitize_text_field($_POST['emotion_color'])); + } +} +add_action('save_post', 'save_emotion_meta_box'); + +function register_custom_meta_boxes() { + register_meta('post', 'title_style', array( + 'show_in_rest' => true, + 'single' => true, + 'type' => 'string', + 'auth_callback' => function() { + return current_user_can('edit_posts'); + } + )); + register_meta('post', 'license', array( + 'show_in_rest' => true, + 'single' => true, + 'type' => 'string', + 'auth_callback' => function() { + return current_user_can('edit_posts'); + } + )); +} +add_action('init', 'register_custom_meta_boxes'); + +function add_custom_meta_box() { + add_meta_box( + 'custom_meta_box_id', + __('Custom Meta Box', 'sakurairo'), + 'render_custom_meta_box', + 'post', // 仅在post内容类型中显示 + 'side', + 'default' + ); +} +add_action('add_meta_boxes', 'add_custom_meta_box'); + +function render_custom_meta_box($post) { + $title_style_value = get_post_meta($post->ID, 'title_style', true); + $license_value = get_post_meta($post->ID, 'license', true); + wp_nonce_field('custom_meta_box_nonce', 'custom_meta_box_nonce_field'); + echo ''; + echo ''; + echo '

'; + echo ''; + echo ''; + echo '

'; + echo '

' . __('For the Title Style, Please fill in the css style, part of the style need to add !important effective, and for the License, please go to Theme Options to learn how to set it up.', 'sakurairo') . '

'; +} + +function save_custom_meta_box($post_id) { + if (!isset($_POST['custom_meta_box_nonce_field']) || !wp_verify_nonce($_POST['custom_meta_box_nonce_field'], 'custom_meta_box_nonce')) { + return; + } + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { + return; + } + if (!current_user_can('edit_post', $post_id)) { + return; + } + if (isset($_POST['title_style'])) { + update_post_meta($post_id, 'title_style', sanitize_text_field($_POST['title_style'])); + } + if (isset($_POST['license'])) { + update_post_meta($post_id, 'license', sanitize_text_field($_POST['license'])); + } +} +add_action('save_post', 'save_custom_meta_box'); + +function include_shuoshuo_in_main_query($query) { + if ($query->is_main_query() && !is_admin() && (is_home() || is_archive())) { + $query->set('post_type', array('post', 'shuoshuo')); + } +} +add_action('pre_get_posts', 'include_shuoshuo_in_main_query'); function admin_lettering() { @@ -1990,17 +2113,23 @@ function change_avatar($avatar) return '😀'; } - // 生成一个合适长度的初始化向量 - $iv_length = openssl_cipher_iv_length('aes-128-cbc'); - $iv = openssl_random_pseudo_bytes($iv_length); - - // 加密数据 - $encrypted = openssl_encrypt($qq_number, 'aes-128-cbc', $sakura_privkey, 0, $iv); - - // 将初始化向量和加密数据一起编码 - $encrypted = urlencode(base64_encode($iv . $encrypted)); - - return '😀'; + // Ensure $sakura_privkey is defined and not null + if (isset($sakura_privkey) && !is_null($sakura_privkey)) { + // 生成一个合适长度的初始化向量 + $iv_length = openssl_cipher_iv_length('aes-128-cbc'); + $iv = openssl_random_pseudo_bytes($iv_length); + + // 加密数据 + $encrypted = openssl_encrypt($qq_number, 'aes-128-cbc', $sakura_privkey, 0, $iv); + + // 将初始化向量和加密数据一起编码 + $encrypted = urlencode(base64_encode($iv . $encrypted)); + + return '😀'; + } else { + // Handle the case where $sakura_privkey is not set or is null + return '😀'; + } } return $avatar; } @@ -2138,64 +2267,6 @@ function check_myisam_support() return false; } -/* - * 随机图 - * 暂移除, 在20个月前功能已被移除,该表应该不存在了。 - */ -// function create_sakura_table() -// { -// if (iro_opt('random_graphs_mts')) { -// global $wpdb, $sakura_image_array, $sakura_mobile_image_array, $sakura_privkey; -// } else { -// global $wpdb, $sakura_image_array, $sakura_privkey; -// } -// $sakura_table_name = $wpdb->base_prefix . 'sakurairo'; -// require_once ABSPATH . "wp-admin/includes/upgrade.php"; -// /// TODO: 移除? -// dbDelta("CREATE TABLE IF NOT EXISTS `" . $sakura_table_name . "` ( -// `mate_key` varchar(50) COLLATE utf8_bin NOT NULL, -// `mate_value` text COLLATE utf8_bin NOT NULL, -// PRIMARY KEY (`mate_key`) -// ) " . (check_myisam_support() ? "ENGINE=MyISAM " : "") . "DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;"); -// //default data -// if (!$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'manifest_json'")) { -// $manifest = array( -// "mate_key" => "manifest_json", -// "mate_value" => file_get_contents(get_template_directory() . "/manifest/manifest.json"), -// ); -// $wpdb->insert($sakura_table_name, $manifest); -// } -// if (iro_opt('random_graphs_mts') && !$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'mobile_manifest_json'")) { -// $mobile_manifest = array( -// "mate_key" => "mobile_manifest_json", -// "mate_value" => file_get_contents(get_template_directory() . "/manifest/manifest_mobile.json"), -// ); -// $wpdb->insert($sakura_table_name, $mobile_manifest); - -// } -// if (!$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'json_time'")) { -// $time = array( -// "mate_key" => "json_time", -// "mate_value" => date("Y-m-d H:i:s", time()), -// ); -// $wpdb->insert($sakura_table_name, $time); -// } -// if (!$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'privkey'")) { -// $privkey = array( -// "mate_key" => "privkey", -// "mate_value" => wp_generate_password(8), -// ); -// $wpdb->insert($sakura_table_name, $privkey); -// } -// //reduce sql query -// $sakura_image_array = $wpdb->get_var("SELECT `mate_value` FROM $sakura_table_name WHERE `mate_key`='manifest_json'"); -// if (iro_opt('random_graphs_mts')) { -// $sakura_mobile_image_array = $wpdb->get_var("SELECT `mate_value` FROM $sakura_table_name WHERE `mate_key`='mobile_manifest_json'"); -// } -// $sakura_privkey = $wpdb->get_var("SELECT `mate_value` FROM $sakura_table_name WHERE `mate_key`='privkey'"); -// } -// add_action('after_setup_theme', 'create_sakura_table'); - //rest api支持 function permalink_tip() { @@ -2236,74 +2307,87 @@ function send_theme_version() } //解析短代码 -add_shortcode('task', 'task_shortcode'); -function task_shortcode($attr, $content = '') -{ - $out = '
' . $content . '
'; - return $out; -} -add_shortcode('warning', 'warning_shortcode'); -function warning_shortcode($attr, $content = '') -{ - $out = '
' . $content . '
'; - return $out; -} -add_shortcode('noway', 'noway_shortcode'); -function noway_shortcode($attr, $content = '') -{ - $out = '
' . $content . '
'; - return $out; -} -add_shortcode('buy', 'buy_shortcode'); -function buy_shortcode($attr, $content = '') -{ - $out = '
' . $content . '
'; - return $out; -} -add_shortcode('ghcard', 'gh_card'); -function gh_card($attr, $content = '') -{ - extract(shortcode_atts(array("path" => ""), $attr)); - return '
Github-Card
'; -} - -add_shortcode('showcard', 'show_card'); -function show_card($attr, $content = '') -{ - extract(shortcode_atts(array("icon" => "", "title" => "", "img" => "", "color" => ""), $attr)); - return '
-
- -
-
-
- -
-
- ' . $title . ' -
-
'; -} - -add_shortcode('conversations', 'conversations'); -function conversations($attr, $content = '') -{ - extract(shortcode_atts(array("avatar" => "", "direction" => "", "username" => ""), $attr)); - if ($avatar == "" && $username != "") { - $user_id = get_user_by('login', $username)->ID; - if ($user_id) { - $avatar = get_avatar_url($user_id, 40); +function register_shortcodes() { + add_shortcode('task', function($attr, $content = '') { + return '
' . $content . '
'; + }); + + add_shortcode('warning', function($attr, $content = '') { + return '
' . $content . '
'; + }); + + add_shortcode('noway', function($attr, $content = '') { + return '
' . $content . '
'; + }); + + add_shortcode('buy', function($attr, $content = '') { + return '
' . $content . '
'; + }); + + add_shortcode('ghcard', function($attr, $content = '') { + $atts = shortcode_atts(array("path" => ""), $attr); + return '
Github-Card
'; + }); + + add_shortcode('showcard', function($attr, $content = '') { + $atts = shortcode_atts(array("icon" => "", "title" => "", "img" => "", "color" => ""), $attr); + return sprintf( + '
+
+ +
+
+ + %s +
+
', + $atts['img'], + $content, + esc_attr($atts['color']), + esc_attr($atts['icon']), + esc_attr($atts['color']), + $atts['title'], + ); + }); + + add_shortcode('conversations', function($attr, $content = '') { + $atts = shortcode_atts(array("avatar" => "", "direction" => "", "username" => ""), $attr); + if (empty($atts['avatar']) && !empty($atts['username'])) { + $user = get_user_by('login', $atts['username']); + if ($user) { + $atts['avatar'] = get_avatar_url($user->ID, 40); + } } - } - $speaker_alt = $username?''.sprintf(__("%s says: ","sakurairo"),$username).'':""; - $output = '
'; - $output .= ""; - $output .= '
'. $speaker_alt . $content . '
'; - $output .= '
'; + $speaker_alt = $atts['username'] ? '' . sprintf(__("%s says: ", "sakurairo"), esc_html($atts['username'])) . '' : ""; + return sprintf( + '
+ +
%s%s
+
', + esc_attr($atts['direction']), + $atts['avatar'], + $speaker_alt, + esc_html($content) + ); + }); - return $output; + add_shortcode('collapse', function($atts, $content = null) { + $atts = shortcode_atts(array("title" => ""), $atts); + ob_start(); + ?> + +
+ + + +
+
+ + ""), $atts); - - ob_start(); // 开启输出缓存 - - // HTML 结构 - ?> -
-
-    -   ==>   -
-
- -
- -// * @return Json -// */ -// function get_photo() -// { -// $postId = $_GET['post']; -// $page = get_post($postId); -// if ($page->post_type != "page") { -// $back['code'] = 201; -// } else { -// $back['code'] = 200; -// $back['imgs'] = array(); -// $dom = new DOMDocument('1.0', 'utf-8'); -// $meta = ''; -// $dom->loadHTML($meta . $page->post_content); -// $imgS = $dom->getElementsByTagName('img'); -// // -// foreach ($imgS as $key => $value) { -// $attr = $value->attributes; -// $header = $attr->getNamedItem('header'); -// $info = $attr->getNamedItem('data-info'); -// $vertical = $attr->getNamedItem('vertical'); - -// //图片资源地址 -// $temp['img'] = $value->attributes->getNamedItem('src')->nodeValue; -// //图片上的标题 -// $temp['header'] = $header->nodeValue ?? null; -// //图片上的信息 -// $temp['info'] = $info->nodeValue ?? null; -// //是否竖向展示 默认false -// $temp['vertical'] = $vertical->nodeValue ?? null; -// array_push($back['imgs'], $temp); -// } -// } -// header('Content-Type:application/json;charset=utf-8'); -// echo json_encode($back); -// exit(); -// } - if (!iro_opt('login_language_opt') == '1') { add_filter('login_display_language_dropdown', '__return_false'); } @@ -2608,7 +2620,7 @@ function iro_output_ip_location_columns($column_name, $comment_id) function exclude_pages_and_categories_from_search($query) { if (!is_admin() && $query->is_search) { // Exclude pages - $query->set('post_type', array('post', 'idea', 'link')); // Include other post types but exclude 'page' + $query->set('post_type', array('post', 'shuoshuo', 'link')); // Include other post types but exclude 'page' // Exclude categories $tax_query = array( diff --git a/header.php b/header.php index d3836392..11fcb079 100644 --- a/header.php +++ b/header.php @@ -17,7 +17,6 @@ $mashiro_logo = iro_opt('mashiro_logo'); $vision_resource_basepath = iro_opt('vision_resource_basepath'); header('X-Frame-Options: SAMEORIGIN'); -header('X-XSS-Protection: 1; mode=block'); ?> - +

diff --git a/tpl/content-thumb.php b/tpl/content-thumb.php index 50adaaf1..f531b908 100644 --- a/tpl/content-thumb.php +++ b/tpl/content-thumb.php @@ -8,30 +8,59 @@ * @package Sakurairo */ -$i = 0; - // Combine posts and shuoshuo $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; -$args = array( + +// Determine if we are on an author page +$is_author_page = is_author(); + +// Query for sticky posts (only on the first page) +if ($paged == 1) { + $sticky_args = array( + 'post_type' => array('post', 'shuoshuo'), + 'post_status' => 'publish', + 'posts_per_page' => -1, // Get all sticky posts + 'post__in' => get_option('sticky_posts'), + 'orderby' => 'post_date', + 'order' => 'DESC', + ); + + if ($is_author_page) { + $sticky_args['author'] = get_the_author_meta('ID'); + } + + $sticky_query = new WP_Query($sticky_args); + + // Display sticky posts + if ($sticky_query->have_posts()) : + while ($sticky_query->have_posts()) : $sticky_query->the_post(); + get_template_part('tpl/content', 'thumbcard'); + endwhile; + endif; +} + +// Query for non-sticky posts +$non_sticky_args = array( 'post_type' => array('post', 'shuoshuo'), 'post_status' => 'publish', 'posts_per_page' => 10, // 每页显示10篇文章 'orderby' => 'post_date', 'order' => 'DESC', - 'author' => get_the_author_meta('ID'), // 只获取当前作者的文章 - 'paged' => $paged + 'paged' => $paged, + 'post__not_in' => get_option('sticky_posts'), + 'ignore_sticky_posts' => 1 ); -$combined_query = new WP_Query($args); +if ($is_author_page) { + $non_sticky_args['author'] = get_the_author_meta('ID'); // 只获取当前作者的文章 +} + +$non_sticky_query = new WP_Query($non_sticky_args); -if ($combined_query->have_posts()) : - while ($combined_query->have_posts()) : $combined_query->the_post(); - $article_class = ''; - if ($i == 1) { - $article_class = ' post-list-show'; - } else { - $i++; - } +// Display non-sticky posts +if ($non_sticky_query->have_posts()) : + while ($non_sticky_query->have_posts()) : $non_sticky_query->the_post(); get_template_part('tpl/content', 'thumbcard'); endwhile; endif; +?> \ No newline at end of file diff --git a/tpl/content-thumbcard.php b/tpl/content-thumbcard.php index 70a7ef35..ec999cc1 100644 --- a/tpl/content-thumbcard.php +++ b/tpl/content-thumbcard.php @@ -89,7 +89,6 @@ function get_post_cover_html() { } } -global $article_class; // Determine post type $post_type = get_post_type(); if ($post_type == 'shuoshuo') { @@ -158,7 +157,7 @@ function get_post_cover_html() { $ai_excerpt = get_post_meta($post->ID, POST_METADATA_KEY, true); $excerpt = has_excerpt(); ?> -
+
diff --git a/tpl/section-article-function.php b/tpl/section-article-function.php index 83fa773f..30874829 100644 --- a/tpl/section-article-function.php +++ b/tpl/section-article-function.php @@ -3,7 +3,9 @@ ?>