Server IP : 103.119.228.120 / Your IP : 3.147.36.106 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 Page Functions * * Functions related to pages and menus. * * @package Kkart\Functions * @version 2.6.0 */ defined( 'ABSPATH' ) || exit; /** * Replace a page title with the endpoint title. * * @param string $title Post title. * @return string */ function kkart_page_endpoint_title( $title ) { global $wp_query; if ( ! is_null( $wp_query ) && ! is_admin() && is_main_query() && in_the_loop() && is_page() && is_kkart_endpoint_url() ) { $endpoint = KKART()->query->get_current_endpoint(); $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; $endpoint_title = KKART()->query->get_endpoint_title( $endpoint, $action ); $title = $endpoint_title ? $endpoint_title : $title; remove_filter( 'the_title', 'kkart_page_endpoint_title' ); } return $title; } add_filter( 'the_title', 'kkart_page_endpoint_title' ); /** * Retrieve page ids - used for myaccount, edit_address, shop, cart, checkout, pay, view_order, terms. returns -1 if no page is found. * * @param string $page Page slug. * @return int */ function kkart_get_page_id( $page ) { if ( 'pay' === $page || 'thanks' === $page ) { kkart_deprecated_argument( __FUNCTION__, '2.1', 'The "pay" and "thanks" pages are no-longer used - an endpoint is added to the checkout instead. To get a valid link use the KKART_Order::get_checkout_payment_url() or KKART_Order::get_checkout_order_received_url() methods instead.' ); $page = 'checkout'; } if ( 'change_password' === $page || 'edit_address' === $page || 'lost_password' === $page ) { kkart_deprecated_argument( __FUNCTION__, '2.1', 'The "change_password", "edit_address" and "lost_password" pages are no-longer used - an endpoint is added to the my-account instead. To get a valid link use the kkart_customer_edit_account_url() function instead.' ); $page = 'myaccount'; } $page = apply_filters( 'kkart_get_' . $page . '_page_id', get_option( 'kkart_' . $page . '_page_id' ) ); return $page ? absint( $page ) : -1; } /** * Retrieve page permalink. * * @param string $page page slug. * @param string|bool $fallback Fallback URL if page is not set. Defaults to home URL. @since 3.4.0. * @return string */ function kkart_get_page_permalink( $page, $fallback = null ) { $page_id = kkart_get_page_id( $page ); $permalink = 0 < $page_id ? get_permalink( $page_id ) : ''; if ( ! $permalink ) { $permalink = is_null( $fallback ) ? get_home_url() : $fallback; } return apply_filters( 'kkart_get_' . $page . '_page_permalink', $permalink ); } /** * Get endpoint URL. * * Gets the URL for an endpoint, which varies depending on permalink settings. * * @param string $endpoint Endpoint slug. * @param string $value Query param value. * @param string $permalink Permalink. * * @return string */ function kkart_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) { if ( ! $permalink ) { $permalink = get_permalink(); } // Map endpoint to options. $query_vars = KKART()->query->get_query_vars(); $endpoint = ! empty( $query_vars[ $endpoint ] ) ? $query_vars[ $endpoint ] : $endpoint; $value = ( get_option( 'kkart_myaccount_edit_address_endpoint', 'edit-address' ) === $endpoint ) ? kkart_edit_address_i18n( $value ) : $value; if ( get_option( 'permalink_structure' ) ) { if ( strstr( $permalink, '?' ) ) { $query_string = '?' . wp_parse_url( $permalink, PHP_URL_QUERY ); $permalink = current( explode( '?', $permalink ) ); } else { $query_string = ''; } $url = trailingslashit( $permalink ); if ( $value ) { $url .= trailingslashit( $endpoint ) . user_trailingslashit( $value ); } else { $url .= user_trailingslashit( $endpoint ); } $url .= $query_string; } else { $url = add_query_arg( $endpoint, $value, $permalink ); } return apply_filters( 'kkart_get_endpoint_url', $url, $endpoint, $value, $permalink ); } /** * Hide menu items conditionally. * * @param array $items Navigation items. * @return array */ function kkart_nav_menu_items( $items ) { if ( ! is_user_logged_in() ) { $customer_logout = get_option( 'kkart_logout_endpoint', 'customer-logout' ); if ( ! empty( $customer_logout ) && ! empty( $items ) && is_array( $items ) ) { foreach ( $items as $key => $item ) { if ( empty( $item->url ) ) { continue; } $path = wp_parse_url( $item->url, PHP_URL_PATH ); $query = wp_parse_url( $item->url, PHP_URL_QUERY ); if ( strstr( $path, $customer_logout ) || strstr( $query, $customer_logout ) ) { unset( $items[ $key ] ); } } } } return $items; } add_filter( 'wp_nav_menu_objects', 'kkart_nav_menu_items', 10 ); /** * Fix active class in nav for shop page. * * @param array $menu_items Menu items. * @return array */ function kkart_nav_menu_item_classes( $menu_items ) { if ( ! is_kkart() ) { return $menu_items; } $shop_page = kkart_get_page_id( 'shop' ); $page_for_posts = (int) get_option( 'page_for_posts' ); if ( ! empty( $menu_items ) && is_array( $menu_items ) ) { foreach ( $menu_items as $key => $menu_item ) { $classes = (array) $menu_item->classes; $menu_id = (int) $menu_item->object_id; // Unset active class for blog page. if ( $page_for_posts === $menu_id ) { $menu_items[ $key ]->current = false; if ( in_array( 'current_page_parent', $classes, true ) ) { unset( $classes[ array_search( 'current_page_parent', $classes, true ) ] ); } if ( in_array( 'current-menu-item', $classes, true ) ) { unset( $classes[ array_search( 'current-menu-item', $classes, true ) ] ); } } elseif ( is_shop() && $shop_page === $menu_id && 'page' === $menu_item->object ) { // Set active state if this is the shop page link. $menu_items[ $key ]->current = true; $classes[] = 'current-menu-item'; $classes[] = 'current_page_item'; } elseif ( is_singular( 'product' ) && $shop_page === $menu_id ) { // Set parent state if this is a product page. $classes[] = 'current_page_parent'; } $menu_items[ $key ]->classes = array_unique( $classes ); } } return $menu_items; } add_filter( 'wp_nav_menu_objects', 'kkart_nav_menu_item_classes', 2 ); /** * Fix active class in wp_list_pages for shop page. * * See details in https://github.com/kkart/kkart/issues/177. * * @param string $pages Pages list. * @return string */ function kkart_list_pages( $pages ) { if ( ! is_kkart() ) { return $pages; } // Remove current_page_parent class from any item. $pages = str_replace( 'current_page_parent', '', $pages ); // Find shop_page_id through kkart options. $shop_page = 'page-item-' . kkart_get_page_id( 'shop' ); if ( is_shop() ) { // Add current_page_item class to shop page. return str_replace( $shop_page, $shop_page . ' current_page_item', $pages ); } // Add current_page_parent class to shop page. return str_replace( $shop_page, $shop_page . ' current_page_parent', $pages ); } add_filter( 'wp_list_pages', 'kkart_list_pages' );