X7ROOT File Manager
Current Path:
/var/softaculous/sitepad/editor/site-data/plugins/kkart-pro/includes
var
/
softaculous
/
sitepad
/
editor
/
site-data
/
plugins
/
kkart-pro
/
includes
/
ðŸ“
..
ðŸ“
abstracts
ðŸ“
admin
📄
body-props-settings.php
(8.18 KB)
📄
class-kkart-ajax.php
(125.64 KB)
📄
class-kkart-api.php
(4.97 KB)
📄
class-kkart-auth.php
(11.66 KB)
📄
class-kkart-autoloader.php
(2.78 KB)
📄
class-kkart-background-emailer.php
(4.59 KB)
📄
class-kkart-background-updater.php
(3.5 KB)
📄
class-kkart-breadcrumb.php
(9.46 KB)
📄
class-kkart-cache-helper.php
(10.71 KB)
📄
class-kkart-cart-fees.php
(3.42 KB)
📄
class-kkart-cart-session.php
(14.46 KB)
📄
class-kkart-cart-totals.php
(27.72 KB)
📄
class-kkart-cart.php
(63.24 KB)
📄
class-kkart-checkout.php
(44.58 KB)
📄
class-kkart-cli.php
(1.02 KB)
📄
class-kkart-comments.php
(12.99 KB)
📄
class-kkart-countries.php
(42.21 KB)
📄
class-kkart-coupon.php
(32.57 KB)
📄
class-kkart-customer-download-log.php
(3.38 KB)
📄
class-kkart-customer-download.php
(10.36 KB)
📄
class-kkart-customer.php
(27.24 KB)
📄
class-kkart-data-exception.php
(1.28 KB)
📄
class-kkart-data-store.php
(5.88 KB)
📄
class-kkart-datetime.php
(2.2 KB)
📄
class-kkart-deprecated-action-hooks.php
(6.54 KB)
📄
class-kkart-deprecated-filter-hooks.php
(6.26 KB)
📄
class-kkart-discounts.php
(30.96 KB)
📄
class-kkart-download-handler.php
(23.37 KB)
📄
class-kkart-emails.php
(22.17 KB)
📄
class-kkart-embed.php
(4.18 KB)
📄
class-kkart-form-handler.php
(43.73 KB)
📄
class-kkart-frontend-scripts.php
(26 KB)
📄
class-kkart-geo-ip.php
(30.43 KB)
📄
class-kkart-geolite-integration.php
(1.99 KB)
📄
class-kkart-geolocation.php
(10.34 KB)
📄
class-kkart-https.php
(4.29 KB)
📄
class-kkart-install.php
(53.84 KB)
📄
class-kkart-integrations.php
(1.29 KB)
📄
class-kkart-log-levels.php
(2.54 KB)
📄
class-kkart-logger.php
(8.21 KB)
📄
class-kkart-meta-data.php
(2.18 KB)
📄
class-kkart-order-factory.php
(3.14 KB)
📄
class-kkart-order-item-coupon.php
(4.02 KB)
📄
class-kkart-order-item-fee.php
(8.7 KB)
📄
class-kkart-order-item-meta.php
(5.8 KB)
📄
class-kkart-order-item-product.php
(13.05 KB)
📄
class-kkart-order-item-shipping.php
(7.75 KB)
📄
class-kkart-order-item-tax.php
(6.44 KB)
📄
class-kkart-order-item.php
(10.69 KB)
📄
class-kkart-order-query.php
(2.52 KB)
📄
class-kkart-order-refund.php
(4.89 KB)
📄
class-kkart-order.php
(61.03 KB)
📄
class-kkart-payment-gateways.php
(5.24 KB)
📄
class-kkart-payment-tokens.php
(5.91 KB)
📄
class-kkart-post-data.php
(17.81 KB)
📄
class-kkart-post-types.php
(26.49 KB)
📄
class-kkart-privacy-background-process.php
(1.69 KB)
📄
class-kkart-privacy-erasers.php
(13.28 KB)
📄
class-kkart-privacy-exporters.php
(14.12 KB)
📄
class-kkart-privacy.php
(14.86 KB)
📄
class-kkart-product-attribute.php
(6.89 KB)
📄
class-kkart-product-download.php
(6.01 KB)
📄
class-kkart-product-external.php
(4.77 KB)
📄
class-kkart-product-factory.php
(3.6 KB)
📄
class-kkart-product-grouped.php
(5.19 KB)
📄
class-kkart-product-query.php
(2.17 KB)
📄
class-kkart-product-simple.php
(1.85 KB)
📄
class-kkart-product-variable.php
(21.47 KB)
📄
class-kkart-product-variation.php
(17.2 KB)
📄
class-kkart-query.php
(30.4 KB)
📄
class-kkart-rate-limiter.php
(2.08 KB)
📄
class-kkart-regenerate-images-request.php
(8.17 KB)
📄
class-kkart-regenerate-images.php
(15.24 KB)
📄
class-kkart-register-wp-admin-settings.php
(4.87 KB)
📄
class-kkart-rest-authentication.php
(19.35 KB)
📄
class-kkart-rest-exception.php
(273 B)
📄
class-kkart-session-handler.php
(10.57 KB)
📄
class-kkart-shipping-rate.php
(5.26 KB)
📄
class-kkart-shipping-zone.php
(13.09 KB)
📄
class-kkart-shipping-zones.php
(4.07 KB)
📄
class-kkart-shipping.php
(11.33 KB)
📄
class-kkart-shortcodes.php
(17.21 KB)
📄
class-kkart-structured-data.php
(17.2 KB)
📄
class-kkart-tax.php
(35.84 KB)
📄
class-kkart-template-loader.php
(18.44 KB)
📄
class-kkart-tracker.php
(22.51 KB)
📄
class-kkart-validation.php
(5.83 KB)
📄
class-kkart-webhook.php
(29.85 KB)
📄
class-kkart.php
(32.69 KB)
ðŸ“
cli
ðŸ“
customizer
ðŸ“
data-stores
ðŸ“
emails
ðŸ“
export
ðŸ“
gateways
ðŸ“
import
ðŸ“
integrations
ðŸ“
interfaces
📄
kkart-account-functions.php
(12.69 KB)
📄
kkart-attribute-functions.php
(20.59 KB)
📄
kkart-cart-functions.php
(17.27 KB)
📄
kkart-conditional-functions.php
(11.8 KB)
📄
kkart-core-functions.php
(78.19 KB)
📄
kkart-coupon-functions.php
(2.65 KB)
📄
kkart-formatting-functions.php
(41.61 KB)
📄
kkart-notice-functions.php
(7.44 KB)
📄
kkart-order-functions.php
(33.53 KB)
📄
kkart-order-item-functions.php
(5.06 KB)
📄
kkart-page-functions.php
(6.92 KB)
📄
kkart-product-functions.php
(47.3 KB)
📄
kkart-rest-functions.php
(10.62 KB)
📄
kkart-stock-functions.php
(12.45 KB)
📄
kkart-template-functions.php
(164.55 KB)
📄
kkart-template-hooks.php
(11.06 KB)
📄
kkart-term-functions.php
(19.45 KB)
📄
kkart-update-functions.php
(64.88 KB)
📄
kkart-user-functions.php
(26.58 KB)
📄
kkart-webhook-functions.php
(5.58 KB)
📄
kkart-widget-functions.php
(2.08 KB)
ðŸ“
legacy
ðŸ“
libraries
ðŸ“
log-handlers
ðŸ“
payment-tokens
📄
premium.php
(943 B)
📄
premium_functions.php
(957 B)
ðŸ“
queue
ðŸ“
rest-api
ðŸ“
shipping
📄
shortcode_functions.php
(70.73 KB)
ðŸ“
shortcodes
📄
shortcodes.php
(265.74 KB)
📄
template.php
(2.85 KB)
ðŸ“
theme-support
ðŸ“
tracks
ðŸ“
traits
ðŸ“
walkers
ðŸ“
wccom-site
ðŸ“
widgets
Editing: class-kkart-comments.php
<?php /** * Comments * * Handle comments (reviews and order notes). * * @package Kkart\Classes\Products * @version 2.3.0 */ defined( 'ABSPATH' ) || exit; /** * Comments class. */ class KKART_Comments { /** * Hook in methods. */ public static function init() { // Rating posts. add_filter( 'comments_open', array( __CLASS__, 'comments_open' ), 10, 2 ); add_filter( 'preprocess_comment', array( __CLASS__, 'check_comment_rating' ), 0 ); add_action( 'comment_post', array( __CLASS__, 'add_comment_rating' ), 1 ); add_action( 'comment_moderation_recipients', array( __CLASS__, 'comment_moderation_recipients' ), 10, 2 ); // Clear transients. add_action( 'wp_update_comment_count', array( __CLASS__, 'clear_transients' ) ); // Secure order notes. add_filter( 'comments_clauses', array( __CLASS__, 'exclude_order_comments' ), 10, 1 ); add_filter( 'comment_feed_where', array( __CLASS__, 'exclude_order_comments_from_feed_where' ) ); // Secure webhook comments. add_filter( 'comments_clauses', array( __CLASS__, 'exclude_webhook_comments' ), 10, 1 ); add_filter( 'comment_feed_where', array( __CLASS__, 'exclude_webhook_comments_from_feed_where' ) ); // Count comments. add_filter( 'wp_count_comments', array( __CLASS__, 'wp_count_comments' ), 10, 2 ); // Delete comments count cache whenever there is a new comment or a comment status changes. add_action( 'wp_insert_comment', array( __CLASS__, 'delete_comments_count_cache' ) ); add_action( 'wp_set_comment_status', array( __CLASS__, 'delete_comments_count_cache' ) ); // Support avatars for `review` comment type. add_filter( 'get_avatar_comment_types', array( __CLASS__, 'add_avatar_for_review_comment_type' ) ); // Review of verified purchase. add_action( 'comment_post', array( __CLASS__, 'add_comment_purchase_verification' ) ); // Set comment type. add_action( 'preprocess_comment', array( __CLASS__, 'update_comment_type' ), 1 ); } /** * See if comments are open. * * @since 3.1.0 * @param bool $open Whether the current post is open for comments. * @param int $post_id Post ID. * @return bool */ public static function comments_open( $open, $post_id ) { if ( 'product' === get_post_type( $post_id ) && ! post_type_supports( 'product', 'comments' ) ) { $open = false; } return $open; } /** * Exclude order comments from queries and RSS. * * This code should exclude shop_order comments from queries. Some queries (like the recent comments widget on the dashboard) are hardcoded. * and are not filtered, however, the code current_user_can( 'read_post', $comment->comment_post_ID ) should keep them safe since only admin and. * shop managers can view orders anyway. * * The frontend view order pages get around this filter by using remove_filter('comments_clauses', array( 'KKART_Comments' ,'exclude_order_comments'), 10, 1 ); * * @param array $clauses A compacted array of comment query clauses. * @return array */ public static function exclude_order_comments( $clauses ) { $clauses['where'] .= ( $clauses['where'] ? ' AND ' : '' ) . " comment_type != 'order_note' "; return $clauses; } /** * Exclude order comments from feed. * * @deprecated 3.1 * @param mixed $join Deprecated. */ public static function exclude_order_comments_from_feed_join( $join ) { kkart_deprecated_function( 'KKART_Comments::exclude_order_comments_from_feed_join', '3.1' ); } /** * Exclude order comments from queries and RSS. * * @param string $where The WHERE clause of the query. * @return string */ public static function exclude_order_comments_from_feed_where( $where ) { return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'order_note' "; } /** * Exclude webhook comments from queries and RSS. * * @since 2.2 * @param array $clauses A compacted array of comment query clauses. * @return array */ public static function exclude_webhook_comments( $clauses ) { $clauses['where'] .= ( $clauses['where'] ? ' AND ' : '' ) . " comment_type != 'webhook_delivery' "; return $clauses; } /** * Exclude webhooks comments from feed. * * @deprecated 3.1 * @param mixed $join Deprecated. */ public static function exclude_webhook_comments_from_feed_join( $join ) { kkart_deprecated_function( 'KKART_Comments::exclude_webhook_comments_from_feed_join', '3.1' ); } /** * Exclude webhook comments from queries and RSS. * * @since 2.1 * @param string $where The WHERE clause of the query. * @return string */ public static function exclude_webhook_comments_from_feed_where( $where ) { return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'webhook_delivery' "; } /** * Validate the comment ratings. * * @param array $comment_data Comment data. * @return array */ public static function check_comment_rating( $comment_data ) { // If posting a comment (not trackback etc) and not logged in. if ( ! is_admin() && isset( $_POST['comment_post_ID'], $_POST['rating'], $comment_data['comment_type'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) && empty( $_POST['rating'] ) && self::is_default_comment_type( $comment_data['comment_type'] ) && kkart_review_ratings_enabled() && kkart_review_ratings_required() ) { // WPCS: input var ok, CSRF ok. wp_die( esc_html__( 'Please rate the product.', 'kkart' ) ); exit; } return $comment_data; } /** * Rating field for comments. * * @param int $comment_id Comment ID. */ public static function add_comment_rating( $comment_id ) { if ( isset( $_POST['rating'], $_POST['comment_post_ID'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) ) { // WPCS: input var ok, CSRF ok. if ( ! $_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok, CSRF ok, sanitization ok. return; } add_comment_meta( $comment_id, 'rating', intval( $_POST['rating'] ), true ); // WPCS: input var ok, CSRF ok. $post_id = isset( $_POST['comment_post_ID'] ) ? absint( $_POST['comment_post_ID'] ) : 0; // WPCS: input var ok, CSRF ok. if ( $post_id ) { self::clear_transients( $post_id ); } } } /** * Modify recipient of review email. * * @param array $emails Emails. * @param int $comment_id Comment ID. * @return array */ public static function comment_moderation_recipients( $emails, $comment_id ) { $comment = get_comment( $comment_id ); if ( $comment && 'product' === get_post_type( $comment->comment_post_ID ) ) { $emails = array( get_option( 'admin_email' ) ); } return $emails; } /** * Ensure product average rating and review count is kept up to date. * * @param int $post_id Post ID. */ public static function clear_transients( $post_id ) { if ( 'product' === get_post_type( $post_id ) ) { $product = kkart_get_product( $post_id ); $product->set_rating_counts( self::get_rating_counts_for_product( $product ) ); $product->set_average_rating( self::get_average_rating_for_product( $product ) ); $product->set_review_count( self::get_review_count_for_product( $product ) ); $product->save(); } } /** * Delete comments count cache whenever there is * new comment or the status of a comment changes. Cache * will be regenerated next time KKART_Comments::wp_count_comments() * is called. */ public static function delete_comments_count_cache() { delete_transient( 'kkart_count_comments' ); } /** * Remove order notes and webhook delivery logs from wp_count_comments(). * * @since 2.2 * @param object $stats Comment stats. * @param int $post_id Post ID. * @return object */ public static function wp_count_comments( $stats, $post_id ) { global $wpdb; if ( 0 === $post_id ) { $stats = get_transient( 'kkart_count_comments' ); if ( ! $stats ) { $stats = array( 'total_comments' => 0, 'all' => 0, ); $count = $wpdb->get_results( " SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('action_log', 'order_note', 'webhook_delivery') GROUP BY comment_approved ", ARRAY_A ); $approved = array( '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed', ); foreach ( (array) $count as $row ) { // Don't count post-trashed toward totals. if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) { $stats['all'] += $row['num_comments']; $stats['total_comments'] += $row['num_comments']; } elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) { $stats['total_comments'] += $row['num_comments']; } if ( isset( $approved[ $row['comment_approved'] ] ) ) { $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; } } foreach ( $approved as $key ) { if ( empty( $stats[ $key ] ) ) { $stats[ $key ] = 0; } } $stats = (object) $stats; set_transient( 'kkart_count_comments', $stats ); } } return $stats; } /** * Make sure WP displays avatars for comments with the `review` type. * * @since 2.3 * @param array $comment_types Comment types. * @return array */ public static function add_avatar_for_review_comment_type( $comment_types ) { return array_merge( $comment_types, array( 'review' ) ); } /** * Determine if a review is from a verified owner at submission. * * @param int $comment_id Comment ID. * @return bool */ public static function add_comment_purchase_verification( $comment_id ) { $comment = get_comment( $comment_id ); $verified = false; if ( 'product' === get_post_type( $comment->comment_post_ID ) ) { $verified = kkart_customer_bought_product( $comment->comment_author_email, $comment->user_id, $comment->comment_post_ID ); add_comment_meta( $comment_id, 'verified', (int) $verified, true ); } return $verified; } /** * Get product rating for a product. Please note this is not cached. * * @since 3.0.0 * @param KKART_Product $product Product instance. * @return float */ public static function get_average_rating_for_product( &$product ) { global $wpdb; $count = $product->get_rating_count(); if ( $count ) { $ratings = $wpdb->get_var( $wpdb->prepare( " SELECT SUM(meta_value) FROM $wpdb->commentmeta LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID WHERE meta_key = 'rating' AND comment_post_ID = %d AND comment_approved = '1' AND meta_value > 0 ", $product->get_id() ) ); $average = number_format( $ratings / $count, 2, '.', '' ); } else { $average = 0; } return $average; } /** * Get product review count for a product (not replies). Please note this is not cached. * * @since 3.0.0 * @param KKART_Product $product Product instance. * @return int */ public static function get_review_count_for_product( &$product ) { global $wpdb; $count = $wpdb->get_var( $wpdb->prepare( " SELECT COUNT(*) FROM $wpdb->comments WHERE comment_parent = 0 AND comment_post_ID = %d AND comment_approved = '1' AND comment_type = 'review' ", $product->get_id() ) ); return $count; } /** * Get product rating count for a product. Please note this is not cached. * * @since 3.0.0 * @param KKART_Product $product Product instance. * @return int[] */ public static function get_rating_counts_for_product( &$product ) { global $wpdb; $counts = array(); $raw_counts = $wpdb->get_results( $wpdb->prepare( " SELECT meta_value, COUNT( * ) as meta_value_count FROM $wpdb->commentmeta LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID WHERE meta_key = 'rating' AND comment_post_ID = %d AND comment_approved = '1' AND meta_value > 0 GROUP BY meta_value ", $product->get_id() ) ); foreach ( $raw_counts as $count ) { $counts[ $count->meta_value ] = absint( $count->meta_value_count ); // WPCS: slow query ok. } return $counts; } /** * Update comment type of product reviews. * * @since 3.5.0 * @param array $comment_data Comment data. * @return array */ public static function update_comment_type( $comment_data ) { if ( ! is_admin() && isset( $_POST['comment_post_ID'], $comment_data['comment_type'] ) && self::is_default_comment_type( $comment_data['comment_type'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) ) { // WPCS: input var ok, CSRF ok. $comment_data['comment_type'] = 'review'; } return $comment_data; } /** * Determines if a comment is of the default type. * * Prior to WordPress 5.5, '' was the default comment type. * As of 5.5, the default type is 'comment'. * * @since 4.3.0 * @param string $comment_type Comment type. * @return bool */ private static function is_default_comment_type( $comment_type ) { return ( '' === $comment_type || 'comment' === $comment_type ); } } KKART_Comments::init();
Upload File
Create Folder