| @@ -10,13 +10,8 @@ | ||
| 10 | 10 | |
| 11 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | 12 | exit( 'This script cannot be accessed directly.' ); |
| 13 | 13 | } |
| 14 | -/** | |
| 15 | - * Post Helpers class. | |
| 16 | - * | |
| 17 | - * @package RadiusTheme\SB | |
| 18 | - */ | |
| 19 | 14 | class PostHelpers { |
| 20 | 15 | /** |
| 21 | 16 | * Query section |
| 22 | 17 | * |
| @@ -183,10 +178,10 @@ | ||
| 183 | 178 | 'default' => 'yes', |
| 184 | 179 | ]; |
| 185 | 180 | $fields['show_short_desc'] = [ |
| 186 | 181 | 'type' => 'switch', |
| 187 | - 'label' => esc_html__( 'Show Excerpt?', 'shopbuilder' ), | |
| 188 | - 'description' => esc_html__( 'Switch on to show post excerpt.', 'shopbuilder' ), | |
| 182 | + 'label' => esc_html__( 'Show Short Description?', 'shopbuilder' ), | |
| 183 | + 'description' => esc_html__( 'Switch on to show post short description.', 'shopbuilder' ), | |
| 189 | 184 | 'label_on' => esc_html__( 'On', 'shopbuilder' ), |
| 190 | 185 | 'label_off' => esc_html__( 'Off', 'shopbuilder' ), |
| 191 | 186 | 'default' => 'yes', |
| 192 | 187 | ]; |
| @@ -455,9 +450,9 @@ | ||
| 455 | 450 | 'show_short_desc' => [ 'yes' ], |
| 456 | 451 | ]; |
| 457 | 452 | |
| 458 | 453 | $fields['post_excerpt_section'] = $obj->start_section( |
| 459 | - esc_html__( 'Excerpt', 'shopbuilder' ), | |
| 454 | + esc_html__( 'Short Description', 'shopbuilder' ), | |
| 460 | 455 | 'settings', |
| 461 | 456 | [], |
| 462 | 457 | $condition |
| 463 | 458 | ); |
| @@ -463,10 +458,10 @@ | ||
| 463 | 458 | ); |
| 464 | 459 | |
| 465 | 460 | $fields['excerpt_limit'] = [ |
| 466 | 461 | 'type' => 'select2', |
| 467 | - 'label' => esc_html__( 'Excerpt Limit', 'shopbuilder' ), | |
| 468 | - 'description' => esc_html__( 'Please select the post excerpt limit.', 'shopbuilder' ), | |
| 462 | + 'label' => esc_html__( 'Short Description Limit', 'shopbuilder' ), | |
| 463 | + 'description' => esc_html__( 'Please select the post short description limit.', 'shopbuilder' ), | |
| 469 | 464 | 'options' => [ |
| 470 | 465 | 'default' => esc_html__( 'Default', 'shopbuilder' ), |
| 471 | 466 | '1-line' => esc_html__( 'Show in 1 line', 'shopbuilder' ), |
| 472 | 467 | '2-lines' => esc_html__( 'Show in 2 lines', 'shopbuilder' ), |
| @@ -480,9 +475,9 @@ | ||
| 480 | 475 | $fields['excerpt_limit_custom'] = [ |
| 481 | 476 | 'type' => 'number', |
| 482 | 477 | 'label' => esc_html__( 'Custom Character Limit', 'shopbuilder' ), |
| 483 | 478 | 'default' => 200, |
| 484 | - 'description' => esc_html__( 'Please enter the post excerpt character limit.', 'shopbuilder' ), | |
| 479 | + 'description' => esc_html__( 'Please enter the post short description character limit.', 'shopbuilder' ), | |
| 485 | 480 | 'condition' => [ 'excerpt_limit' => [ 'custom' ] ], |
| 486 | 481 | ]; |
| 487 | 482 | |
| 488 | 483 | $fields['post_excerpt_section_end'] = $obj->end_section(); |
| @@ -594,13 +589,11 @@ | ||
| 594 | 589 | } |
| 595 | 590 | return apply_filters( 'rtsb/elementor/render/post_meta_dataset_final', $data, $meta, $raw_settings ); |
| 596 | 591 | } |
| 597 | 592 | /** |
| 598 | - * Function to get post arg dataset. | |
| 593 | + * Gets posts arguments. | |
| 599 | 594 | * |
| 600 | - * @param array $settings Settings array. | |
| 601 | - * | |
| 602 | - * @return array | |
| 595 | + * @return array posts data. | |
| 603 | 596 | */ |
| 604 | 597 | public static function get_post_arg_dataset( $settings ) { |
| 605 | 598 | global $post; |
| 606 | 599 | |
| @@ -607,18 +600,15 @@ | ||
| 607 | 600 | $title_limit_custom = $settings['title_limit_custom'] ?? ''; |
| 608 | 601 | $excerpt_limit_custom = $settings['excerpt_limit_custom'] ?? '200'; |
| 609 | 602 | return [ |
| 610 | 603 | 'title' => Fns::text_truncation( get_the_title( $post->ID ), $title_limit_custom ), |
| 611 | - 'excerpt' => Fns::text_truncation( do_shortcode( get_post_field( 'post_excerpt', $post->ID ) ), $excerpt_limit_custom ), | |
| 604 | + 'excerpt' => Fns::text_truncation( do_shortcode( get_post_field( 'post_content', $post->ID ) ), $excerpt_limit_custom ), | |
| 612 | 605 | 'img_html' => self::render_posts_thumbnail( $post->ID, $settings ), |
| 613 | 606 | ]; |
| 614 | 607 | } |
| 615 | 608 | /** |
| 616 | - * Get post thumbnail HTML | |
| 609 | + * Function to generate item class. | |
| 617 | 610 | * |
| 618 | - * @param int $post_id Post ID. | |
| 619 | - * @param array $settings Settings array. | |
| 620 | - * | |
| 621 | 611 | * @return string |
| 622 | 612 | */ |
| 623 | 613 | public static function render_posts_thumbnail( $post_id, $settings ) { |
| 624 | 614 | $c_image_size = RenderHelpers::get_data( $settings, 'img_dimension', [] ); |
| @@ -634,16 +624,11 @@ | ||
| 634 | 624 | false |
| 635 | 625 | ) : null; |
| 636 | 626 | } |
| 637 | 627 | /** |
| 638 | - * Generate the formatted HTML list of categories or tags for the current post. | |
| 628 | + * Prints HTML with category list information about theme categories. | |
| 639 | 629 | * |
| 640 | - * Retrieves either post categories or tags based on the provided type and | |
| 641 | - * returns them wrapped in a span element with a corresponding CSS class. | |
| 642 | - * | |
| 643 | - * @param string $type The taxonomy type to display. Accepts 'category' or 'tag'. Default 'category'. | |
| 644 | - * | |
| 645 | - * @return string HTML markup with the taxonomy list, or an empty string if none found. | |
| 630 | + * @return string | |
| 646 | 631 | */ |
| 647 | 632 | public static function rtsb_posted_taxonomy( $type = 'category' ) { |
| 648 | 633 | $categories_list = get_the_category_list( self::rtsb_list_item_separator() ); |
| 649 | 634 | if ( 'tag' === $type ) { |
| @@ -673,17 +658,11 @@ | ||
| 673 | 658 | ); |
| 674 | 659 | return sprintf( '<span class="posted-on">%s</span>', $time_string ); |
| 675 | 660 | } |
| 676 | 661 | /** |
| 677 | - * Generate formatted HTML for the post author section. | |
| 662 | + * Prints HTML with meta information about theme author. | |
| 678 | 663 | * |
| 679 | - * Outputs the author name (linked to their posts archive) optionally | |
| 680 | - * prefixed by a custom label (e.g., "Posted by"). Both the prefix and | |
| 681 | - * author name are wrapped in appropriate markup for styling. | |
| 682 | - * | |
| 683 | - * @param string $prefix Optional text to display before the author name. Default empty. | |
| 684 | - * | |
| 685 | - * @return string HTML markup containing the author information. | |
| 664 | + * @return string | |
| 686 | 665 | */ |
| 687 | 666 | public static function rtsb_posted_by( $prefix = '' ) { |
| 688 | 667 | return sprintf( |
| 689 | 668 | /* translators: %1$s: Optional prefix (e.g., "Posted by"), %2$s: Author name with a link. */ |
| @@ -691,18 +670,9 @@ | ||
| 691 | 670 | $prefix ? '<span class="prefix">' . $prefix . '</span>' : '', |
| 692 | 671 | '<span class="byline"><a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a></span>' |
| 693 | 672 | ); |
| 694 | 673 | } |
| 695 | - /** | |
| 696 | - * Retrieve the formatted comments count text for the current post. | |
| 697 | - * | |
| 698 | - * Returns a translated string showing the number of comments, | |
| 699 | - * automatically handling singular/plural forms. | |
| 700 | - * | |
| 701 | - * Example: "Comment: 1" or "Comments: 5". | |
| 702 | - * | |
| 703 | - * @return string Formatted comments count text. | |
| 704 | - */ | |
| 674 | + | |
| 705 | 675 | public static function get_post_comments_number() { |
| 706 | 676 | $comments_number = get_comments_number(); |
| 707 | 677 | // translators: %s is for comments number. |
| 708 | 678 | $comments = sprintf( _n( 'Comment: %s', 'Comments: %s', $comments_number, 'shopbuilder' ), number_format_i18n( $comments_number ) ); |
| @@ -707,16 +677,8 @@ | ||
| 707 | 677 | // translators: %s is for comments number. |
| 708 | 678 | $comments = sprintf( _n( 'Comment: %s', 'Comments: %s', $comments_number, 'shopbuilder' ), number_format_i18n( $comments_number ) ); |
| 709 | 679 | return $comments; |
| 710 | 680 | } |
| 711 | - /** | |
| 712 | - * Get the separator used between post taxonomy list items. | |
| 713 | - * | |
| 714 | - * Returns an HTML span element used as a separator between categories or tags. | |
| 715 | - * The output can be customized using the `rtsb_post_list_item_separator` filter. | |
| 716 | - * | |
| 717 | - * @return string HTML separator markup. | |
| 718 | - */ | |
| 719 | 681 | public static function rtsb_list_item_separator() { |
| 720 | 682 | $separator = sprintf( |
| 721 | 683 | /* translators: Used between list items, there is a space after the comma. */ |
| 722 | 684 | "<span class='%s'>%s</span>", |
| @@ -725,18 +687,8 @@ | ||
| 725 | 687 | ); |
| 726 | 688 | |
| 727 | 689 | return apply_filters( 'rtsb_post_list_item_separator', $separator ); |
| 728 | 690 | } |
| 729 | - /** | |
| 730 | - * Calculate and display the estimated reading time for the current post. | |
| 731 | - * | |
| 732 | - * Counts the words in the post content (after removing shortcodes and HTML tags) | |
| 733 | - * and estimates reading time based on 200 words per minute. Outputs a formatted | |
| 734 | - * HTML span with the reading duration (e.g., "1 min read", "5 mins read", | |
| 735 | - * "Less than a minute", or "2 hours read"). | |
| 736 | - * | |
| 737 | - * @return string HTML-wrapped reading time text. | |
| 738 | - */ | |
| 739 | 691 | public static function rtsb_reading_time() { |
| 740 | 692 | $post_content = get_post()->post_content; |
| 741 | 693 | $post_content = strip_shortcodes( $post_content ); |
| 742 | 694 | $post_content = wp_strip_all_tags( $post_content ); |
| @@ -747,9 +699,9 @@ | ||
| 747 | 699 | $result = esc_html__( 'Less than a minute', 'shopbuilder' ); |
| 748 | 700 | } elseif ( $reading_time > 60 ) { |
| 749 | 701 | /* translators: %s is reading time. */ |
| 750 | 702 | $result = sprintf( esc_html__( '%s hours read', 'shopbuilder' ), floor( $reading_time / 60 ) ); |
| 751 | - } elseif ( 1 == $reading_time ) { | |
| 703 | + } elseif ( $reading_time == 1 ) { | |
| 752 | 704 | $result = esc_html__( '1 min read', 'shopbuilder' ); |
| 753 | 705 | } else { |
| 754 | 706 | $result = sprintf( |
| 755 | 707 | /* translators: %s is reading time. */ |
| @@ -759,27 +711,8 @@ | ||
| 759 | 711 | } |
| 760 | 712 | |
| 761 | 713 | return '<span class="meta-reading-time meta-item">' . $result . '</span> '; |
| 762 | 714 | } |
| 763 | - /** | |
| 764 | - * Display formatted post view count with CSS status classes. | |
| 765 | - * | |
| 766 | - * Retrieves the post view count stored in the `rt_post_views` meta key, | |
| 767 | - * formats the number for display, and assigns a visual status class based | |
| 768 | - * on popularity (e.g., "rising", "high", "very-high"). | |
| 769 | - * | |
| 770 | - * Outputs an HTML span containing the view number and label | |
| 771 | - * ("View" or "Views") along with an optional CSS class. | |
| 772 | - * | |
| 773 | - * - very-high: more than 1000 views | |
| 774 | - * - high: more than 100 views | |
| 775 | - * - rising: more than 5 views | |
| 776 | - * | |
| 777 | - * @param string $text Optional custom text (currently unused). | |
| 778 | - * @param int $post_id Optional post ID. Defaults to current post. | |
| 779 | - * | |
| 780 | - * @return string HTML markup for the post view count. | |
| 781 | - */ | |
| 782 | 715 | public static function rtsb_post_views( $text = '', $post_id = 0 ) { |
| 783 | 716 | |
| 784 | 717 | if ( empty( $post_id ) ) { |
| 785 | 718 | $post_id = get_the_ID(); |
| @@ -798,15 +731,15 @@ | ||
| 798 | 731 | $views_class = 'high'; |
| 799 | 732 | } elseif ( $view_count > 5 ) { |
| 800 | 733 | $views_class = 'rising'; |
| 801 | 734 | } |
| 802 | - } elseif ( '' == $view_count ) { | |
| 735 | + } elseif ( $view_count == '' ) { | |
| 803 | 736 | $view_count = 0; |
| 804 | 737 | } else { |
| 805 | 738 | $view_count = 0; |
| 806 | 739 | } |
| 807 | 740 | |
| 808 | - if ( 1 == $view_count ) { | |
| 741 | + if ( $view_count == 1 ) { | |
| 809 | 742 | $shopbuilder_view_html = esc_html__( 'View', 'shopbuilder' ); |
| 810 | 743 | } else { |
| 811 | 744 | $shopbuilder_view_html = esc_html__( 'Views', 'shopbuilder' ); |
| 812 | 745 | } |
| @@ -933,8 +866,11 @@ | ||
| 933 | 866 | ], |
| 934 | 867 | 'toggle' => true, |
| 935 | 868 | 'selectors' => $selectors['content_hr_alignment'] , |
| 936 | 869 | 'default' => 'start', |
| 870 | + // 'condition' => [ | |
| 871 | + // 'layout_style!' => [ 'rtsb-post-grid-layout1','rtsb-post-grid-layout2','rtsb-post-grid-layout3' ], | |
| 872 | + // ], | |
| 937 | 873 | ]; |
| 938 | 874 | $fields = Fns::insert_controls( 'post_list_item_style_color_note', $fields, $extra_controls3 ); |
| 939 | 875 | return $fields; |
| 940 | 876 | } |
| @@ -1115,9 +1051,9 @@ | ||
| 1115 | 1051 | * @param object $obj Reference object. |
| 1116 | 1052 | * |
| 1117 | 1053 | * @return array |
| 1118 | 1054 | */ |
| 1119 | - public static function button_style( $obj ) { | |
| 1055 | + public static function button_style( $obj, $type = 'primary' ) { | |
| 1120 | 1056 | $condition = [ |
| 1121 | 1057 | 'show_read_more_btn' => 'yes', |
| 1122 | 1058 | ]; |
| 1123 | 1059 | $css_selectors = $obj->selectors['readmore_button_style']; |
| @@ -1143,18 +1079,8 @@ | ||
| 1143 | 1079 | 'border_radius' => [ $css_selectors['border_radius'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;' ], |
| 1144 | 1080 | ]; |
| 1145 | 1081 | |
| 1146 | 1082 | $fields = ControlHelper::general_elementor_style( 'readmore_button_style', $title, $obj, $condition, $selectors ); |
| 1147 | - | |
| 1148 | - // Redirect the text-decoration sub-field to `.text-wrap` (an unshielded span that wraps the label); the shield-blocked `<a>` can't reach text inside its inline-flex child. | |
| 1149 | - $fields['rtsb_el_readmore_button_style_typography']['fields_options'] = [ | |
| 1150 | - 'text_decoration' => [ | |
| 1151 | - 'selectors' => [ | |
| 1152 | - $css_selectors['text_decoration'] => 'text-decoration: {{VALUE}};', | |
| 1153 | - ], | |
| 1154 | - ], | |
| 1155 | - ]; | |
| 1156 | - | |
| 1157 | 1083 | unset( |
| 1158 | 1084 | $fields['readmore_button_style_alignment'], |
| 1159 | 1085 | ); |
| 1160 | 1086 | $extra_controls['readmore_button_style_border_radius'] = [ |
| @@ -1565,17 +1491,8 @@ | ||
| 1565 | 1491 | ]; |
| 1566 | 1492 | |
| 1567 | 1493 | $fields = ControlHelper::general_elementor_style( 'post_taxonomy_style', $title, $obj, [], $selectors, $conditions ); |
| 1568 | 1494 | |
| 1569 | - // Force text-decoration with !important to beat the `.rtsb-elementor-container a { text-decoration: none !important; }` framework shield (see _el-global.scss). | |
| 1570 | - $fields['rtsb_el_post_taxonomy_style_typography']['fields_options'] = [ | |
| 1571 | - 'text_decoration' => [ | |
| 1572 | - 'selectors' => [ | |
| 1573 | - $css_selectors['typography'] => 'text-decoration: {{VALUE}} !important;', | |
| 1574 | - ], | |
| 1575 | - ], | |
| 1576 | - ]; | |
| 1577 | - | |
| 1578 | 1495 | unset( |
| 1579 | 1496 | $fields['post_taxonomy_style_alignment'], |
| 1580 | 1497 | ); |
| 1581 | 1498 | $extra_controls['taxonomy_border_radius'] = [ |
| @@ -1601,27 +1518,8 @@ | ||
| 1601 | 1518 | ]; |
| 1602 | 1519 | $fields = Fns::insert_controls( 'post_taxonomy_style_spacing_note', $fields, $extra_controls2, true ); |
| 1603 | 1520 | return $fields; |
| 1604 | 1521 | } |
| 1605 | - /** | |
| 1606 | - * Get the list of available image hover effects for post widgets. | |
| 1607 | - * | |
| 1608 | - * Returns an associative array of hover effect CSS class names mapped | |
| 1609 | - * to their corresponding human-readable labels. The list can be modified | |
| 1610 | - * by third-party developers through the | |
| 1611 | - * `rtsb/general/widget/post_widget_image_hover_effect` filter. | |
| 1612 | - * | |
| 1613 | - * Available effects: | |
| 1614 | - * - None | |
| 1615 | - * - Scale In | |
| 1616 | - * - Scale Out | |
| 1617 | - * - Slide Up | |
| 1618 | - * - Slide Down | |
| 1619 | - * - Slide Right | |
| 1620 | - * - Slide Left | |
| 1621 | - * | |
| 1622 | - * @return array List of image hover effect options (class => label). | |
| 1623 | - */ | |
| 1624 | 1522 | public static function rtsb_post_image_hover_effect() { |
| 1625 | 1523 | return apply_filters( |
| 1626 | 1524 | 'rtsb/general/widget/post_widget_image_hover_effect', |
| 1627 | 1525 | [ |
| @@ -1634,22 +1532,9 @@ | ||
| 1634 | 1532 | 'rtsb-gw-img-slide-left' => __( 'Slide Left', 'shopbuilder' ), |
| 1635 | 1533 | ] |
| 1636 | 1534 | ); |
| 1637 | 1535 | } |
| 1638 | - /** | |
| 1639 | - * Get CSS selectors used for styling pagination elements in Elementor widgets. | |
| 1640 | - * | |
| 1641 | - * Returns an associative array mapping style control keys (e.g., typography, | |
| 1642 | - * alignment, colors, borders) to the corresponding CSS selectors used within | |
| 1643 | - * the widget. These selectors are primarily applied when rendering pagination | |
| 1644 | - * for posts, archives, and "load more" buttons inside the ShopBuilder Elementor | |
| 1645 | - * container. | |
| 1646 | - * | |
| 1647 | - * This helps ensure all pagination-related style controls are centralized and | |
| 1648 | - * consistent across widgets. | |
| 1649 | - * | |
| 1650 | - * @return array List of pagination style selectors keyed by control name. | |
| 1651 | - */ | |
| 1536 | + | |
| 1652 | 1537 | public static function post_pagination_selectors() { |
| 1653 | 1538 | return [ |
| 1654 | 1539 | 'typography' => '{{WRAPPER}} .rtsb-elementor-container .rtsb-pagination ul.pagination-list li a, {{WRAPPER}} .rtsb-elementor-container .rtsb-pagination ul.pagination-list li span, {{WRAPPER}} .rtsb-elementor-container .rtsb-pagination-wrap .rtsb-load-more button, {{WRAPPER}} .rtsb-elementor-container .rtsb-archive-pagination-wrap .rtsb-load-more button', |
| 1655 | 1540 | 'alignment' => '{{WRAPPER}} .rtsb-elementor-container .rtsb-pagination ul.pagination-list, {{WRAPPER}} .rtsb-elementor-container .rtsb-pagination-wrap, {{WRAPPER}} .rtsb-elementor-container .rtsb-archive-pagination-wrap', |