Changeset 3339941
- Timestamp:
- 08/06/2025 12:43:08 AM (7 months ago)
- Location:
- visualwebs-ml
- Files:
-
- 4 edited
-
tags/5.4.3/includes/class-visualwebs-ml-semantic-search-queue-table.php (modified) (4 diffs)
-
tags/5.4.3/vendor/visualwebs-ml/Helper/Data.php (modified) (14 diffs)
-
trunk/includes/class-visualwebs-ml-semantic-search-queue-table.php (modified) (4 diffs)
-
trunk/vendor/visualwebs-ml/Helper/Data.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
visualwebs-ml/tags/5.4.3/includes/class-visualwebs-ml-semantic-search-queue-table.php
r3319473 r3339941 270 270 if ( 'enabled' === $filter ) { 271 271 $where .= $wpdb->prepare( ' AND job_status = %d', 1 ); 272 } elseif ( 'pending' === $filter ) { 273 $where .= $wpdb->prepare( ' AND job_sync_status = %d', 0 ); 272 274 } elseif ( 'synced' === $filter ) { 273 275 $where .= $wpdb->prepare( ' AND job_sync_status = %d', 1 ); … … 471 473 $filters = array( 472 474 'all' => 'All', 475 'pending' => 'Pending', 473 476 'enabled' => 'Enabled', 474 477 'synced' => 'Synced', … … 681 684 $current_url = remove_query_arg( array( 'paged', '_wpnonce' ), $current_url ); 682 685 686 if ( ! empty( $columns['cb'] ) ) { 687 static $cb_counter = 1; 688 $columns['cb'] = '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" /> 689 <label for="cb-select-all-' . $cb_counter . '">' . 690 '<span class="screen-reader-text">' . 691 /* translators: Hidden accessibility text. */ 692 __( 'Select All' ) . 693 '</span>' . 694 '</label>'; 695 ++$cb_counter; 696 } 697 683 698 foreach ( $columns as $column_key => $column_display_name ) { 684 $class = array( 'manage-column', "column-$column_key" ); 699 $class = array( 'manage-column', "column-$column_key" ); 700 $aria_sort_attr = ''; 701 $abbr_attr = ''; 702 $order_text = ''; 703 704 if ( in_array( $column_key, $hidden, true ) ) { 705 $class[] = 'hidden'; 706 } 707 708 if ( 'cb' === $column_key ) { 709 $class[] = 'check-column'; 710 } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { 711 $class[] = 'num'; 712 } 713 714 if ( $column_key === $primary ) { 715 $class[] = 'column-primary'; 716 } 685 717 686 718 if ( isset( $sortable[ $column_key ] ) ) { 687 719 $orderby = $sortable[ $column_key ][0]; 688 720 721 // Add sanitization and validation. 689 722 if ( isset( $_GET['orderby'] ) || isset( $_GET['order'] ) ) { 690 723 check_admin_referer( 'visualwebs-ml-semantic-queue' ); … … 706 739 707 740 $column_display_name = sprintf( 708 '<a href="%1$s"><span>%2$s</span></a>', 741 '<a href="%1$s">' . 742 '<span>%2$s</span>' . 743 '<span class="sorting-indicators">' . 744 '<span class="sorting-indicator asc" aria-hidden="true"></span>' . 745 '<span class="sorting-indicator desc" aria-hidden="true"></span>' . 746 '</span>' . 747 '%3$s' . 748 '</a>', 709 749 esc_url( $sort_url ), 710 $column_display_name 750 $column_display_name, 751 $order_text 711 752 ); 712 $class[] = 'sortable'; 713 } 714 715 printf( 716 '<th scope="col" id="%1$s" class="%2$s">%3$s</th>', 717 esc_attr( $column_key ), 718 esc_attr( implode( ' ', $class ) ), 719 wp_kses_post( $column_display_name ) 720 ); 753 754 $class[] = 'sortable'; 755 } 756 757 $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; 758 $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; 759 $id = $with_id ? "id='$column_key'" : ''; 760 761 if ( ! empty( $class ) ) { 762 $class = "class='" . implode( ' ', $class ) . "'"; 763 } 764 765 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 766 echo "<$tag $scope $id $class $aria_sort_attr $abbr_attr>$column_display_name</$tag>"; 721 767 } 722 768 } -
visualwebs-ml/tags/5.4.3/vendor/visualwebs-ml/Helper/Data.php
r3337157 r3339941 372 372 373 373 if (is_product_category() || is_category() || $category) { 374 $category = $category ?: get_queried_object();375 $categoryName = $category->name;374 $category = $category ?: get_queried_object(); 375 $categoryName = $category->name; 376 376 $categoryDescription = ''; 377 $taxonomy = $category->taxonomy;377 $taxonomy = $category->taxonomy; 378 378 379 379 $term = get_term($category->term_id, $taxonomy); 380 if ($term && ! is_wp_error($term)) {380 if ($term && ! is_wp_error($term)) { 381 381 $categoryDescription = apply_filters('term_description', $term->description); 382 382 $categoryDescription = do_shortcode($categoryDescription); … … 384 384 385 385 if ($categoryDescription) { 386 386 $url = get_term_link($category); 387 387 if ($isSemanticCall) { 388 return $categoryDescription; 389 } 390 388 return $categoryDescription . "\nFrontend URL for the category: $url"; 389 } 391 390 if ($taxonomy == 'product_cat') { 392 391 return sprintf( 393 'This page contains a listing of products for the category "%s" with this description: "%s". ',392 'This page contains a listing of products for the category "%s" with this description: "%s". Frontend URL for the category: %s', 394 393 $categoryName, 395 $categoryDescription 394 $categoryDescription, 395 $url 396 396 ); 397 397 } else { 398 398 return sprintf( 399 'This page contains a listing of posts for the category "%s" with this description: "%s". ',399 'This page contains a listing of posts for the category "%s" with this description: "%s". Frontend URL for the category: %s', 400 400 $categoryName, 401 $categoryDescription 401 $categoryDescription, 402 $url 402 403 ); 403 404 } … … 415 416 protected function getProductDescription($product = null, $withDynamicInfo = true) 416 417 { 417 if (! $product) {418 if (! $product) { 418 419 $product = wc_get_product(); 419 420 } 420 421 421 if (! $product) {422 if (! $product) { 422 423 return ''; 423 424 } 424 425 425 if (! $product instanceof \WC_Product) {426 if (! $product instanceof \WC_Product) { 426 427 return ''; 427 428 } … … 441 442 // Process content 442 443 $productDescription = ''; 443 $post = get_post($product->get_id());444 $post = get_post($product->get_id()); 444 445 if ($post) { 445 446 $productDescription = apply_filters('the_content', $post->post_content); … … 447 448 } 448 449 449 $sku = $product->get_sku();450 $price = wc_price($product->get_price());450 $sku = $product->get_sku(); 451 $price = wc_price($product->get_price()); 451 452 $categories = $this->getCategoryNames($product); 452 453 453 454 // Get stock information 454 $stockStatus = $product->is_in_stock() ? 'In stock' : 'Out of stock';455 $stockStatus = $product->is_in_stock() ? 'In stock' : 'Out of stock'; 455 456 $stockQuantity = $product->get_stock_quantity(); 456 $stockInfo = $stockQuantity !== null ? "Stock quantity: $stockQuantity" : "Stock status: $stockStatus";457 $stockInfo = $stockQuantity !== null ? "Stock quantity: $stockQuantity" : "Stock status: $stockStatus"; 457 458 458 459 $description = sprintf( … … 472 473 } 473 474 475 $frontendAttributes = array(); 476 foreach ($product->get_attributes() as $attribute) { 477 if ($attribute->get_visible()) { 478 $label = wc_attribute_label($attribute->get_name()); 479 $value = $product->get_attribute($attribute->get_name()); 480 if (is_string($value) && trim($value) !== '' && strtolower($value) !== 'no') { 481 $frontendAttributes[] = "$label: $value"; 482 } 483 } 484 } 485 if ($frontendAttributes) { 486 $description .= "\nFrontend attributes:\n" . implode("\n", $frontendAttributes); 487 } 488 474 489 switch ($productType) { 475 490 case 'simple': … … 477 492 478 493 case 'variable': 479 $variations = $product->get_available_variations(); 480 $variationDescriptions = []; 481 494 $variations = $product->get_available_variations(); 495 $variationDescriptions = array(); 482 496 483 497 foreach ($variations as $variation) { 484 $attributes = [];498 $attributes = array(); 485 499 foreach ($variation['attributes'] as $key => $value) { 486 500 $attributes[] = sprintf('%s: %s', wc_attribute_label($key), $value); 487 501 } 488 502 489 $variationStockStatus = $variation['is_in_stock'] ? 'In stock' : 'Out of stock';503 $variationStockStatus = $variation['is_in_stock'] ? 'In stock' : 'Out of stock'; 490 504 $variationStockQuantity = isset($variation['max_qty']) ? $variation['max_qty'] : 'N/A'; 491 505 … … 501 515 } 502 516 503 504 517 if ($variationDescriptions) { 505 518 $description .= ' Available variations: ' . implode(' ', $variationDescriptions); … … 508 521 509 522 case 'grouped': 510 $children = $product->get_children();511 $childDescriptions = [];523 $children = $product->get_children(); 524 $childDescriptions = array(); 512 525 513 526 foreach ($children as $childId) { … … 537 550 case 'bundle': 538 551 if (method_exists($product, 'get_bundled_items')) { 539 $bundledItems = $product->get_bundled_items();540 $bundleDescriptions = [];552 $bundledItems = $product->get_bundled_items(); 553 $bundleDescriptions = array(); 541 554 542 555 foreach ($bundledItems as $bundledItem) { … … 584 597 case 'subscription': 585 598 $billingInterval = $product->get_meta('_subscription_period_interval'); 586 $billingPeriod = $product->get_meta('_subscription_period');587 $trialLength = $product->get_meta('_subscription_trial_length');588 $trialPeriod = $product->get_meta('_subscription_trial_period');599 $billingPeriod = $product->get_meta('_subscription_period'); 600 $trialLength = $product->get_meta('_subscription_trial_length'); 601 $trialPeriod = $product->get_meta('_subscription_trial_period'); 589 602 590 603 $subscriptionDetails = $withDynamicInfo … … 613 626 614 627 case 'variable-subscription': 615 $variations = $product->get_available_variations();616 $variationDescriptions = [];628 $variations = $product->get_available_variations(); 629 $variationDescriptions = array(); 617 630 618 631 foreach ($variations as $variation) { 619 $variationId = $variation['variation_id'];632 $variationId = $variation['variation_id']; 620 633 $variationProduct = wc_get_product($variationId); 621 634 622 635 $billingInterval = $variationProduct->get_meta('_subscription_period_interval'); // e.g., "1" 623 $billingPeriod = $variationProduct->get_meta('_subscription_period'); // e.g., "month", "year"624 $trialLength = $variationProduct->get_meta('_subscription_trial_length'); // e.g., "7"625 $trialPeriod = $variationProduct->get_meta('_subscription_trial_period'); // e.g., "day", "week"626 627 $attributes = [];636 $billingPeriod = $variationProduct->get_meta('_subscription_period'); // e.g., "month", "year" 637 $trialLength = $variationProduct->get_meta('_subscription_trial_length'); // e.g., "7" 638 $trialPeriod = $variationProduct->get_meta('_subscription_trial_period'); // e.g., "day", "week" 639 640 $attributes = array(); 628 641 foreach ($variation['attributes'] as $key => $value) { 629 642 $attributes[] = sprintf('%s: %s', wc_attribute_label($key), $value); … … 666 679 } 667 680 681 $frontendUrl = get_permalink($product->get_id()); 682 $description .= "\nFrontend URL for the product: $frontendUrl"; 668 683 669 684 if ($withDynamicInfo) { … … 694 709 protected function getCmsPageContent($page = null) 695 710 { 696 return $this->getPostContent($page); 711 $content = $this->getPostContent($page); 712 if ($page) { 713 $url = get_permalink($page); 714 } else { 715 $queried = get_queried_object(); 716 $url = $queried && isset($queried->ID) ? get_permalink($queried->ID) : ''; 717 } 718 if ($url) { 719 $content .= "\nFrontend URL for the page: $url"; 720 } 721 return $content; 697 722 } 698 723 -
visualwebs-ml/trunk/includes/class-visualwebs-ml-semantic-search-queue-table.php
r3319473 r3339941 270 270 if ( 'enabled' === $filter ) { 271 271 $where .= $wpdb->prepare( ' AND job_status = %d', 1 ); 272 } elseif ( 'pending' === $filter ) { 273 $where .= $wpdb->prepare( ' AND job_sync_status = %d', 0 ); 272 274 } elseif ( 'synced' === $filter ) { 273 275 $where .= $wpdb->prepare( ' AND job_sync_status = %d', 1 ); … … 471 473 $filters = array( 472 474 'all' => 'All', 475 'pending' => 'Pending', 473 476 'enabled' => 'Enabled', 474 477 'synced' => 'Synced', … … 681 684 $current_url = remove_query_arg( array( 'paged', '_wpnonce' ), $current_url ); 682 685 686 if ( ! empty( $columns['cb'] ) ) { 687 static $cb_counter = 1; 688 $columns['cb'] = '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" /> 689 <label for="cb-select-all-' . $cb_counter . '">' . 690 '<span class="screen-reader-text">' . 691 /* translators: Hidden accessibility text. */ 692 __( 'Select All' ) . 693 '</span>' . 694 '</label>'; 695 ++$cb_counter; 696 } 697 683 698 foreach ( $columns as $column_key => $column_display_name ) { 684 $class = array( 'manage-column', "column-$column_key" ); 699 $class = array( 'manage-column', "column-$column_key" ); 700 $aria_sort_attr = ''; 701 $abbr_attr = ''; 702 $order_text = ''; 703 704 if ( in_array( $column_key, $hidden, true ) ) { 705 $class[] = 'hidden'; 706 } 707 708 if ( 'cb' === $column_key ) { 709 $class[] = 'check-column'; 710 } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { 711 $class[] = 'num'; 712 } 713 714 if ( $column_key === $primary ) { 715 $class[] = 'column-primary'; 716 } 685 717 686 718 if ( isset( $sortable[ $column_key ] ) ) { 687 719 $orderby = $sortable[ $column_key ][0]; 688 720 721 // Add sanitization and validation. 689 722 if ( isset( $_GET['orderby'] ) || isset( $_GET['order'] ) ) { 690 723 check_admin_referer( 'visualwebs-ml-semantic-queue' ); … … 706 739 707 740 $column_display_name = sprintf( 708 '<a href="%1$s"><span>%2$s</span></a>', 741 '<a href="%1$s">' . 742 '<span>%2$s</span>' . 743 '<span class="sorting-indicators">' . 744 '<span class="sorting-indicator asc" aria-hidden="true"></span>' . 745 '<span class="sorting-indicator desc" aria-hidden="true"></span>' . 746 '</span>' . 747 '%3$s' . 748 '</a>', 709 749 esc_url( $sort_url ), 710 $column_display_name 750 $column_display_name, 751 $order_text 711 752 ); 712 $class[] = 'sortable'; 713 } 714 715 printf( 716 '<th scope="col" id="%1$s" class="%2$s">%3$s</th>', 717 esc_attr( $column_key ), 718 esc_attr( implode( ' ', $class ) ), 719 wp_kses_post( $column_display_name ) 720 ); 753 754 $class[] = 'sortable'; 755 } 756 757 $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; 758 $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; 759 $id = $with_id ? "id='$column_key'" : ''; 760 761 if ( ! empty( $class ) ) { 762 $class = "class='" . implode( ' ', $class ) . "'"; 763 } 764 765 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 766 echo "<$tag $scope $id $class $aria_sort_attr $abbr_attr>$column_display_name</$tag>"; 721 767 } 722 768 } -
visualwebs-ml/trunk/vendor/visualwebs-ml/Helper/Data.php
r3337157 r3339941 372 372 373 373 if (is_product_category() || is_category() || $category) { 374 $category = $category ?: get_queried_object();375 $categoryName = $category->name;374 $category = $category ?: get_queried_object(); 375 $categoryName = $category->name; 376 376 $categoryDescription = ''; 377 $taxonomy = $category->taxonomy;377 $taxonomy = $category->taxonomy; 378 378 379 379 $term = get_term($category->term_id, $taxonomy); 380 if ($term && ! is_wp_error($term)) {380 if ($term && ! is_wp_error($term)) { 381 381 $categoryDescription = apply_filters('term_description', $term->description); 382 382 $categoryDescription = do_shortcode($categoryDescription); … … 384 384 385 385 if ($categoryDescription) { 386 386 $url = get_term_link($category); 387 387 if ($isSemanticCall) { 388 return $categoryDescription; 389 } 390 388 return $categoryDescription . "\nFrontend URL for the category: $url"; 389 } 391 390 if ($taxonomy == 'product_cat') { 392 391 return sprintf( 393 'This page contains a listing of products for the category "%s" with this description: "%s". ',392 'This page contains a listing of products for the category "%s" with this description: "%s". Frontend URL for the category: %s', 394 393 $categoryName, 395 $categoryDescription 394 $categoryDescription, 395 $url 396 396 ); 397 397 } else { 398 398 return sprintf( 399 'This page contains a listing of posts for the category "%s" with this description: "%s". ',399 'This page contains a listing of posts for the category "%s" with this description: "%s". Frontend URL for the category: %s', 400 400 $categoryName, 401 $categoryDescription 401 $categoryDescription, 402 $url 402 403 ); 403 404 } … … 415 416 protected function getProductDescription($product = null, $withDynamicInfo = true) 416 417 { 417 if (! $product) {418 if (! $product) { 418 419 $product = wc_get_product(); 419 420 } 420 421 421 if (! $product) {422 if (! $product) { 422 423 return ''; 423 424 } 424 425 425 if (! $product instanceof \WC_Product) {426 if (! $product instanceof \WC_Product) { 426 427 return ''; 427 428 } … … 441 442 // Process content 442 443 $productDescription = ''; 443 $post = get_post($product->get_id());444 $post = get_post($product->get_id()); 444 445 if ($post) { 445 446 $productDescription = apply_filters('the_content', $post->post_content); … … 447 448 } 448 449 449 $sku = $product->get_sku();450 $price = wc_price($product->get_price());450 $sku = $product->get_sku(); 451 $price = wc_price($product->get_price()); 451 452 $categories = $this->getCategoryNames($product); 452 453 453 454 // Get stock information 454 $stockStatus = $product->is_in_stock() ? 'In stock' : 'Out of stock';455 $stockStatus = $product->is_in_stock() ? 'In stock' : 'Out of stock'; 455 456 $stockQuantity = $product->get_stock_quantity(); 456 $stockInfo = $stockQuantity !== null ? "Stock quantity: $stockQuantity" : "Stock status: $stockStatus";457 $stockInfo = $stockQuantity !== null ? "Stock quantity: $stockQuantity" : "Stock status: $stockStatus"; 457 458 458 459 $description = sprintf( … … 472 473 } 473 474 475 $frontendAttributes = array(); 476 foreach ($product->get_attributes() as $attribute) { 477 if ($attribute->get_visible()) { 478 $label = wc_attribute_label($attribute->get_name()); 479 $value = $product->get_attribute($attribute->get_name()); 480 if (is_string($value) && trim($value) !== '' && strtolower($value) !== 'no') { 481 $frontendAttributes[] = "$label: $value"; 482 } 483 } 484 } 485 if ($frontendAttributes) { 486 $description .= "\nFrontend attributes:\n" . implode("\n", $frontendAttributes); 487 } 488 474 489 switch ($productType) { 475 490 case 'simple': … … 477 492 478 493 case 'variable': 479 $variations = $product->get_available_variations(); 480 $variationDescriptions = []; 481 494 $variations = $product->get_available_variations(); 495 $variationDescriptions = array(); 482 496 483 497 foreach ($variations as $variation) { 484 $attributes = [];498 $attributes = array(); 485 499 foreach ($variation['attributes'] as $key => $value) { 486 500 $attributes[] = sprintf('%s: %s', wc_attribute_label($key), $value); 487 501 } 488 502 489 $variationStockStatus = $variation['is_in_stock'] ? 'In stock' : 'Out of stock';503 $variationStockStatus = $variation['is_in_stock'] ? 'In stock' : 'Out of stock'; 490 504 $variationStockQuantity = isset($variation['max_qty']) ? $variation['max_qty'] : 'N/A'; 491 505 … … 501 515 } 502 516 503 504 517 if ($variationDescriptions) { 505 518 $description .= ' Available variations: ' . implode(' ', $variationDescriptions); … … 508 521 509 522 case 'grouped': 510 $children = $product->get_children();511 $childDescriptions = [];523 $children = $product->get_children(); 524 $childDescriptions = array(); 512 525 513 526 foreach ($children as $childId) { … … 537 550 case 'bundle': 538 551 if (method_exists($product, 'get_bundled_items')) { 539 $bundledItems = $product->get_bundled_items();540 $bundleDescriptions = [];552 $bundledItems = $product->get_bundled_items(); 553 $bundleDescriptions = array(); 541 554 542 555 foreach ($bundledItems as $bundledItem) { … … 584 597 case 'subscription': 585 598 $billingInterval = $product->get_meta('_subscription_period_interval'); 586 $billingPeriod = $product->get_meta('_subscription_period');587 $trialLength = $product->get_meta('_subscription_trial_length');588 $trialPeriod = $product->get_meta('_subscription_trial_period');599 $billingPeriod = $product->get_meta('_subscription_period'); 600 $trialLength = $product->get_meta('_subscription_trial_length'); 601 $trialPeriod = $product->get_meta('_subscription_trial_period'); 589 602 590 603 $subscriptionDetails = $withDynamicInfo … … 613 626 614 627 case 'variable-subscription': 615 $variations = $product->get_available_variations();616 $variationDescriptions = [];628 $variations = $product->get_available_variations(); 629 $variationDescriptions = array(); 617 630 618 631 foreach ($variations as $variation) { 619 $variationId = $variation['variation_id'];632 $variationId = $variation['variation_id']; 620 633 $variationProduct = wc_get_product($variationId); 621 634 622 635 $billingInterval = $variationProduct->get_meta('_subscription_period_interval'); // e.g., "1" 623 $billingPeriod = $variationProduct->get_meta('_subscription_period'); // e.g., "month", "year"624 $trialLength = $variationProduct->get_meta('_subscription_trial_length'); // e.g., "7"625 $trialPeriod = $variationProduct->get_meta('_subscription_trial_period'); // e.g., "day", "week"626 627 $attributes = [];636 $billingPeriod = $variationProduct->get_meta('_subscription_period'); // e.g., "month", "year" 637 $trialLength = $variationProduct->get_meta('_subscription_trial_length'); // e.g., "7" 638 $trialPeriod = $variationProduct->get_meta('_subscription_trial_period'); // e.g., "day", "week" 639 640 $attributes = array(); 628 641 foreach ($variation['attributes'] as $key => $value) { 629 642 $attributes[] = sprintf('%s: %s', wc_attribute_label($key), $value); … … 666 679 } 667 680 681 $frontendUrl = get_permalink($product->get_id()); 682 $description .= "\nFrontend URL for the product: $frontendUrl"; 668 683 669 684 if ($withDynamicInfo) { … … 694 709 protected function getCmsPageContent($page = null) 695 710 { 696 return $this->getPostContent($page); 711 $content = $this->getPostContent($page); 712 if ($page) { 713 $url = get_permalink($page); 714 } else { 715 $queried = get_queried_object(); 716 $url = $queried && isset($queried->ID) ? get_permalink($queried->ID) : ''; 717 } 718 if ($url) { 719 $content .= "\nFrontend URL for the page: $url"; 720 } 721 return $content; 697 722 } 698 723
Note: See TracChangeset
for help on using the changeset viewer.