is_order_edit_page() || $this->is_order_post_page() ) { wp_enqueue_style( 'thickbox' ); wp_enqueue_style( 'woocommerce-delivery-notes-admin', WooCommerce_Delivery_Notes::$plugin_url . 'css/admin.css', '', WooCommerce_Delivery_Notes::$plugin_version ); } } /** * Add the scripts */ public function add_scripts() { if ( $this->is_order_edit_page() || $this->is_order_post_page() ) { wp_enqueue_script( 'thickbox' ); wp_enqueue_script( 'woocommerce-delivery-notes-print-link', WooCommerce_Delivery_Notes::$plugin_url . 'js/jquery.print-link.js', array( 'jquery' ), WooCommerce_Delivery_Notes::$plugin_version, false ); wp_enqueue_script( 'woocommerce-delivery-notes-admin', WooCommerce_Delivery_Notes::$plugin_url . 'js/admin.js', array( 'jquery', 'woocommerce-delivery-notes-print-link' ), WooCommerce_Delivery_Notes::$plugin_version, false ); } } /** * Is order edit page */ public function is_order_edit_page() { global $typenow, $pagenow; if ( 'shop_order' === $typenow && 'edit.php' === $pagenow ) { return true; } else { return false; } } /** * Is order edit page */ public function is_order_post_page() { global $typenow, $pagenow; if ( 'shop_order' === $typenow && ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) ) { return true; } else { return false; } } /** * Add print actions to the orders listing * * @param object $order Order Object. */ public function add_listing_actions( $order ) { $wdn_order_id = ( version_compare( get_option( 'woocommerce_version' ), '3.0.0', '>=' ) ) ? $order->get_id() : $order->id; ?> $referer_args['post_type'], ); if ( isset( $referer_args['post_status'] ) ) { $args = wp_parse_args( array( 'post_status' => $referer_args['post_status'] ), $args ); } if ( isset( $referer_args['paged'] ) ) { $args = wp_parse_args( array( 'paged' => $referer_args['paged'] ), $args ); } if ( isset( $referer_args['orderby'] ) ) { $args = wp_parse_args( array( 'orderby' => $referer_args['orderby'] ), $args ); } if ( isset( $referer_args['order'] ) ) { $args = wp_parse_args( array( 'orderby' => $referer_args['order'] ), $args ); } // do the action. $post_ids = array_map( 'absint', (array) $_REQUEST['post'] ); $total = count( $post_ids ); $url = wcdn_get_print_link( $post_ids, $template_type ); // generate more args and the sendback string. $args = wp_parse_args( array( $report_action => true, 'total' => $total, 'print_url' => rawurlencode( $url ), ), $args ); $sendback = add_query_arg( $args, '' ); wp_safe_redirect( $sendback ); exit; } /** * Show confirmation message that orders are printed */ public function confirm_bulk_actions() { if ( $this->is_order_edit_page() ) { foreach ( WCDN_Print::$template_registrations as $template_registration ) { if ( isset( $_REQUEST[ 'printed_' . $template_registration['type'] ] ) ) { // use singular or plural form. $total = isset( $_REQUEST['total'] ) ? absint( $_REQUEST['total'] ) : 0; if ( $total <= 1 ) { $message = $template_registration['labels']['message']; } else { $message = $template_registration['labels']['message_plural']; } ?>