Changeset 3458821
- Timestamp:
- 02/11/2026 09:32:12 AM (7 weeks ago)
- Location:
- infility-global/trunk
- Files:
-
- 4 edited
-
infility_global.php (modified) (3 diffs)
-
widgets/elementor-tab/elementor-tab.php (modified) (5 diffs)
-
widgets/elementor-tab/includes/widgets/elementor_nav_posts.php (modified) (2 diffs)
-
widgets/elementor-tab/js/elementor_nav_posts.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
infility-global/trunk/infility_global.php
r3452498 r3458821 4 4 Plugin URI: https://www.infility.cn/ 5 5 Description: Infility公共插件 6 Version: 2.14.5 26 Version: 2.14.53 7 7 Author: Infility 8 8 Author URI: https://www.infility.cn/ … … 140 140 v2.14.43 (20251217) Ben: 修复导入文件漏洞添加nonce 141 141 v2.14.52 (20260203) Step: 修复 infility_get_data 接口的安全问题。 142 v2.14.53 (20260211) Ben: 新增elepost列表组件的当前分类post功能。 142 143 */ 143 144 … … 145 146 function __construct() 146 147 { 147 define( 'INFILITY_GLOBAL_VERSION', '2.14.5 1' );148 define( 'INFILITY_GLOBAL_VERSION', '2.14.53' ); 148 149 define( 'INFILITY_GLOBAL_PATH', plugin_dir_path( __FILE__ ) ); // fullpath/wp-content/plugins/infility-global/ // 有斜杠 149 150 define( 'INFILITY_GLOBAL_URL', plugins_url( '/', __FILE__ ) ); // https://the_domain/wp-content/plugins/infility-global/ // 斜杠是自己加的 -
infility-global/trunk/widgets/elementor-tab/elementor-tab.php
r3429478 r3458821 105 105 $show_hierarchical = sanitize_text_field($_POST['show_hierarchical']); 106 106 $post_type = isset($_POST['post_type']) ? sanitize_text_field($_POST['post_type']) : 'post'; 107 108 $is_curr_post = isset($_POST['is_curr_post']) ? sanitize_text_field($_POST['is_curr_post']) : 'no'; 109 $current_post_id = isset($_POST['current_post_id']) ? intval($_POST['current_post_id']) : 0; 110 $current_term_id = isset($_POST['current_term_id']) ? intval($_POST['current_term_id']) : 0; 107 111 108 112 // 确定要使用的分类法 … … 135 139 } 136 140 137 $categories = get_terms($taxonomy_args); 141 if ($is_curr_post === 'yes') { 142 $current_category_id = 0; 143 if ($current_term_id) { 144 $term = get_term($current_term_id, $taxonomy_name); 145 if ($term && !is_wp_error($term)) { 146 $current_category_id = $current_term_id; 147 } 148 } elseif ($current_post_id) { 149 $terms = wp_get_post_terms($current_post_id, $taxonomy_name); 150 if (!empty($terms) && !is_wp_error($terms)) { 151 $current_category_id = $terms[0]->term_id; 152 } 153 } 154 155 if ($current_category_id) { 156 // Get children 157 $taxonomy_args['child_of'] = $current_category_id; 158 $children = get_terms($taxonomy_args); 159 160 // Get parent (current category) 161 $parent = get_term($current_category_id, $taxonomy_name); 162 163 if (!is_wp_error($children) && !is_wp_error($parent)) { 164 $categories = array_merge([$parent], $children); 165 } else { 166 $categories = get_terms($taxonomy_args); 167 } 168 } else { 169 $categories = get_terms($taxonomy_args); 170 } 171 } else { 172 $categories = get_terms($taxonomy_args); 173 } 138 174 139 175 if (is_wp_error($categories)) { … … 275 311 $pagination_type = sanitize_text_field($_POST['pagination_type']); 276 312 $paged = isset($_POST['paged']) ? intval($_POST['paged']) : 1; 313 314 $is_curr_post = isset($_POST['is_curr_post']) ? sanitize_text_field($_POST['is_curr_post']) : 'no'; 315 $current_post_id = isset($_POST['current_post_id']) ? intval($_POST['current_post_id']) : 0; 316 $current_term_id = isset($_POST['current_term_id']) ? intval($_POST['current_term_id']) : 0; 317 $taxonomy_type = isset($_POST['taxonomy_type']) ? sanitize_text_field($_POST['taxonomy_type']) : ''; 318 $custom_taxonomy = isset($_POST['custom_taxonomy']) ? sanitize_text_field($_POST['custom_taxonomy']) : ''; 277 319 278 320 // 验证文章类型是否存在 … … 291 333 ]; 292 334 335 // Determine taxonomy 336 $taxonomy = ''; 337 if ($taxonomy_type === 'custom_taxonomy' && !empty($custom_taxonomy)) { 338 $taxonomy = $custom_taxonomy; 339 } elseif (!empty($taxonomy_type)) { 340 $taxonomy = $taxonomy_type; 341 } else { 342 $taxonomies = get_object_taxonomies($post_type); 343 if (!empty($taxonomies)) { 344 $taxonomy = $taxonomies[0]; 345 } 346 } 347 293 348 // 如果分类不是"all",添加分类过滤 294 349 if ($category !== 'all') { 295 // 获取文章类型的默认分类法 296 $taxonomies = get_object_taxonomies($post_type); 297 if (!empty($taxonomies)) { 298 $taxonomy = $taxonomies[0]; // 使用第一个分类法 299 350 if ($taxonomy) { 300 351 // 检查是否是一级分类,如果是则包含其子分类 301 352 $term = get_term($category, $taxonomy); … … 323 374 } 324 375 } 376 } elseif ($is_curr_post === 'yes') { 377 // Category is 'all', but we want to filter by current context 378 $current_category_id = 0; 379 if ($current_term_id) { 380 // Verify term belongs to taxonomy 381 $term = get_term($current_term_id, $taxonomy); 382 if ($term && !is_wp_error($term)) { 383 $current_category_id = $current_term_id; 384 } 385 } elseif ($current_post_id) { 386 $terms = wp_get_post_terms($current_post_id, $taxonomy); 387 if (!empty($terms) && !is_wp_error($terms)) { 388 $current_category_id = $terms[0]->term_id; 389 } 390 } 391 392 if ($current_category_id) { 393 // Same logic as selected category: include children 394 $child_terms = get_terms([ 395 'taxonomy' => $taxonomy, 396 'parent' => $current_category_id, 397 'hide_empty' => false, 398 ]); 399 400 $category_ids = [$current_category_id]; 401 if (!is_wp_error($child_terms)) { 402 foreach ($child_terms as $child_term) { 403 $category_ids[] = $child_term->term_id; 404 } 405 } 406 407 $args['tax_query'] = [ 408 [ 409 'taxonomy' => $taxonomy, 410 'field' => 'term_id', 411 'terms' => $category_ids, 412 'operator' => 'IN', 413 ] 414 ]; 415 } 325 416 } 326 417 -
infility-global/trunk/widgets/elementor-tab/includes/widgets/elementor_nav_posts.php
r3437335 r3458821 143 143 ], 144 144 'description' => '输入自定义分类法的名称(slug)', 145 ] 146 ); 147 148 $this->add_control( 149 'is_curr_post', 150 [ 151 'label' => '是否显示当前分类post', 152 'type' => \Elementor\Controls_Manager::SWITCHER, 153 'default' => 'no', 154 'label_on' => '是', 155 'label_off' => '否', 156 'description' => '是否显示分类的层级结构', 145 157 ] 146 158 ); … … 1069 1081 show_excerpt: '<?php echo esc_js($settings['show_excerpt']); ?>', 1070 1082 show_date: '<?php echo esc_js($settings['show_date']); ?>', 1071 show_category: '<?php echo esc_js($settings['show_category']); ?>' 1083 show_category: '<?php echo esc_js($settings['show_category']); ?>', 1084 is_curr_post: '<?php echo esc_js($settings['is_curr_post']); ?>', 1085 current_post_id: '<?php echo get_the_ID(); ?>', 1086 current_term_id: '<?php echo (is_category() || is_tax() || is_tag()) ? get_queried_object_id() : ""; ?>' 1072 1087 }; 1073 1088 -
infility-global/trunk/widgets/elementor-tab/js/elementor_nav_posts.js
r3351823 r3458821 530 530 taxonomy_type: settings.taxonomy_type, 531 531 custom_taxonomy: settings.custom_taxonomy, 532 is_curr_post: settings.is_curr_post, 533 current_post_id: settings.current_post_id, 534 current_term_id: settings.current_term_id, 532 535 show_hierarchical: settings.show_hierarchical, 533 536 nonce: window.elementor_nav_posts_nonce || '' … … 685 688 category: category, 686 689 post_type: settings.post_type, 690 taxonomy_type: settings.taxonomy_type, 691 custom_taxonomy: settings.custom_taxonomy, 687 692 posts_per_page: settings.show_pagination === 'yes' ? settings.posts_per_page_pagination : settings.posts_per_page, 688 693 orderby: settings.orderby, … … 691 696 image_resolution: settings.image_resolution, 692 697 pagination_type: settings.pagination_type, 698 is_curr_post: settings.is_curr_post, 699 current_post_id: settings.current_post_id, 700 current_term_id: settings.current_term_id, 693 701 paged:page, 694 702 nonce: window.elementor_nav_posts_nonce || ''
Note: See TracChangeset
for help on using the changeset viewer.