Thursday, July 28, 2022
HomeWordPress DevelopmentMethods to substitute perform in baby theme?

Methods to substitute perform in baby theme?


There’s a perform within the dad or mum theme:

perform latest_comments($list_number = 5, $cut_length = 50)
{
    world $wpdb, $output;
    $feedback = $wpdb->get_results($wpdb->put together("SELECT comment_ID, comment_post_ID, comment_author, comment_author_email, comment_date, comment_content FROM {$wpdb->feedback} LEFT OUTER JOIN {$wpdb->posts} ON {$wpdb->feedback}.comment_post_ID = {$wpdb->posts}.ID WHERE comment_approved = '1' AND (comment_type="" OR comment_type="remark") AND user_id != '1' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT %d", $list_number));
    foreach ($feedback as $remark) {
        $nickname = esc_attr($comment->comment_author) ?: __('匿名', 'kratos');
        $output .= '<a href="' . get_the_permalink($comment->comment_post_ID) . '#commentform">
            <div class="meta clearfix">
                <div class="avatar float-left">' . get_avatar($remark, 60) . '</div>
                <div class="profile d-block">
                    <span class="date">' . $nickname . ' ' . __('发布于 ', 'kratos') . timeago($comment->comment_date) . '(' . wp_date(__('m月d日', 'kratos'), strtotime($comment->comment_date)) . ')</span>
                    <span class="message d-block">' . convert_smilies(esc_attr(string_cut(strip_tags($comment->comment_content), $cut_length))) . '</span>
                </div>
            </div>
        </a>';
    }
    return $output;
}

And I wish to substitute it with following perform in baby theme(the distinction is elimination of avatar float-left):

perform latest_comments($list_number = 5, $cut_length = 50)
{
    world $wpdb, $output;
    $feedback = $wpdb->get_results($wpdb->put together("SELECT comment_ID, comment_post_ID, comment_author, comment_author_email, comment_date, comment_content FROM {$wpdb->feedback} LEFT OUTER JOIN {$wpdb->posts} ON {$wpdb->feedback}.comment_post_ID = {$wpdb->posts}.ID WHERE comment_approved = '1' AND (comment_type="" OR comment_type="remark") AND user_id != '1' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT %d", $list_number));
    foreach ($feedback as $remark) {
        $nickname = esc_attr($comment->comment_author) ?: __('匿名', 'kratos');
        $output .= '<a href="' . get_the_permalink($comment->comment_post_ID) . '#commentform">
            <div class="meta clearfix">
                <div class="profile d-block">
                    <span class="date">' . $nickname . ' ' . __('发布于 ', 'kratos') . timeago($comment->comment_date) . '(' . wp_date(__('m月d日', 'kratos'), strtotime($comment->comment_date)) . ')</span>
                    <span class="message d-block">' . convert_smilies(esc_attr(string_cut(strip_tags($comment->comment_content), $cut_length))) . '</span>
                </div>
            </div>
        </a>';
    }
    return $output;
}

I’ve search two strategies: the primary is pluggable perform, which isn’t match to me because the dad or mum theme is the third-party. The second is specify the precedence of the perform. Nonetheless there isn’t a add_action code after which I can not insert add_action('after_setup_theme', 'my_child_theme_function', 20) because the tutorial do. Can anybody give different strategies?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments