Server IP : 103.119.228.120 / Your IP : 52.15.217.86 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/softaculous/sitepad/editor/site-data/plugins/kkart-pro/includes/ |
Upload File : |
<?php /** * Kkart product embed * * @version 2.4.11 * @package Kkart\Classes\Embed */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Embed Class which handles any Kkart Products that are embedded on this site or another site. */ class KKART_Embed { /** * Init embed class. * * @since 2.4.11 */ public static function init() { // Filter all of the content that's going to be embedded. add_filter( 'the_excerpt_embed', array( __CLASS__, 'the_excerpt' ), 10 ); // Make sure no comments display. Doesn't make sense for products. add_action( 'embed_content_meta', array( __CLASS__, 'remove_comments_button' ), 5 ); // In the comments place let's display the product rating. add_action( 'embed_content_meta', array( __CLASS__, 'get_ratings' ), 5 ); // Add some basic styles. add_action( 'embed_head', array( __CLASS__, 'print_embed_styles' ) ); } /** * Remove comments button on product embeds. * * @since 2.6.0 */ public static function remove_comments_button() { if ( self::is_embedded_product() ) { remove_action( 'embed_content_meta', 'print_embed_comments_button' ); } } /** * Check if this is an embedded product - to make sure we don't mess up regular posts. * * @since 2.4.11 * @return bool */ public static function is_embedded_product() { if ( function_exists( 'is_embed' ) && is_embed() && is_product() ) { return true; } return false; } /** * Create the excerpt for embedded products - we want to add the buy button to it. * * @since 2.4.11 * @param string $excerpt Embed short description. * @return string */ public static function the_excerpt( $excerpt ) { global $post; // Get product. $_product = kkart_get_product( get_the_ID() ); // Make sure we're only affecting embedded products. if ( self::is_embedded_product() ) { echo '<p><span class="kkart-embed-price">' . $_product->get_price_html() . '</span></p>'; // WPCS: XSS ok. if ( ! empty( $post->post_excerpt ) ) { ob_start(); kkart_template_single_excerpt(); $excerpt = ob_get_clean(); } // Add the button. $excerpt .= self::product_buttons(); } return $excerpt; } /** * Create the button to go to the product page for embedded products. * * @since 2.4.11 * @return string */ public static function product_buttons() { $_product = kkart_get_product( get_the_ID() ); $buttons = array(); $button = '<a href="%s" class="wp-embed-more kkart-embed-button">%s</a>'; if ( $_product->is_type( 'simple' ) && $_product->is_purchasable() && $_product->is_in_stock() ) { $buttons[] = sprintf( $button, esc_url( add_query_arg( 'add-to-cart', get_the_ID(), kkart_get_cart_url() ) ), esc_html__( 'Buy now', 'kkart' ) ); } $buttons[] = sprintf( $button, get_the_permalink(), esc_html__( 'Read more', 'kkart' ) ); return '<p>' . implode( ' ', $buttons ) . '</p>'; } /** * Prints the markup for the rating stars. * * @since 2.4.11 */ public static function get_ratings() { // Make sure we're only affecting embedded products. if ( ! self::is_embedded_product() ) { return; } $_product = kkart_get_product( get_the_ID() ); if ( $_product && $_product->get_average_rating() > 0 ) { ?> <div class="kkart-embed-rating"> <?php printf( /* translators: %s: average rating */ esc_html__( 'Rated %s out of 5', 'kkart' ), esc_html( $_product->get_average_rating() ) ); ?> </div> <?php } } /** * Basic styling. */ public static function print_embed_styles() { if ( ! self::is_embedded_product() ) { return; } ?> <style type="text/css"> a.kkart-embed-button { border-radius: 4px; border: 1px solid #ddd; box-shadow: 0px 1px 0 0px rgba(0, 0, 0, 0.05); display:inline-block; padding: .5em; } a.kkart-embed-button:hover, a.kkart-embed-button:focus { border: 1px solid #ccc; box-shadow: 0px 1px 0 0px rgba(0, 0, 0, 0.1); color: #999; text-decoration: none; } .wp-embed-excerpt p { margin: 0 0 1em; } .kkart-embed-price { display: block; opacity: .75; font-weight: 700; margin-top: -.75em; } .kkart-embed-rating { display: inline-block; } </style> <?php } } KKART_Embed::init();