/** * Display the order status data meta box * * @since 1.0.0 */ public function order_status_data_meta_box() { global $post; $status = new WC_Order_Status_Manager_Order_Status($post->ID); wp_nonce_field('wc_order_status_manager_save_data', 'wc_order_status_manager_meta_nonce'); ?> <div id="order_status_options" class="panel woocommerce_options_panel"> <div class="options_group"> <?php // Status Name woocommerce_wp_text_input(array('id' => 'post_title', 'label' => __('Name', WC_Order_Status_Manager::TEXT_DOMAIN), 'value' => $post->post_title)); // Disable slug editing for core statuses $custom_attributes = array(); if ($status->is_core_status()) { $custom_attributes['disabled'] = 'disabled'; } // Slug woocommerce_wp_text_input(array('id' => 'post_name', 'label' => __('Slug', WC_Order_Status_Manager::TEXT_DOMAIN), 'value' => $post->post_name, 'custom_attributes' => $custom_attributes, 'desc_tip' => true, 'description' => __('Optional. If left blank, the slug will be automatically generated from the name. Maximum: 17 characters.', WC_Order_Status_Manager::TEXT_DOMAIN))); // Description woocommerce_wp_textarea_input(array('id' => 'post_excerpt', 'label' => __('Description', WC_Order_Status_Manager::TEXT_DOMAIN), 'desc_tip' => true, 'description' => __('Optional status description. If set, this will be shown to customers while viewing an order.', WC_Order_Status_Manager::TEXT_DOMAIN), 'value' => htmlspecialchars_decode($post->post_excerpt, ENT_QUOTES))); ?> </div><!-- // .options_group --> <div class="options_group"> <?php // Color woocommerce_wp_text_input(array('id' => '_color', 'label' => __('Color', WC_Order_Status_Manager::TEXT_DOMAIN), 'type' => 'text', 'class' => 'colorpick', 'default' => '#000000', 'desc_tip' => true, 'description' => __('Color displayed behind the order status image or name', WC_Order_Status_Manager::TEXT_DOMAIN))); // Status Icon $icon = $status->get_icon(); $icon_attachment_src = ''; if (is_numeric($icon)) { $icon_attachment_src = wp_get_attachment_image_src($icon, 'wc_order_status_icon'); } ?> <p class="form-field _icon_field"> <label for="_icon"><?php _e('Icon', WC_Order_Status_Manager::TEXT_DOMAIN); ?> </label> <input type="text" id="_icon" name="_icon" class="short" value="<?php echo esc_attr($status->get_icon()); ?> " data-icon-image="<?php echo esc_attr($icon_attachment_src ? $icon_attachment_src[0] : ''); ?> "> <a href="#_icon" class="button upload-icon upload-icon-image" data-uploader-button-text="<?php _e('Set as status icon', WC_Order_Status_Manager::TEXT_DOMAIN); ?> "><?php _e("Select File", WC_Order_Status_Manager::TEXT_DOMAIN); ?> </a> <img class="help_tip" data-tip="<?php _e("Optional status icon. If not supplied, then Name will be displayed to represent the status", WC_Order_Status_Manager::TEXT_DOMAIN); ?> " src="<?php echo esc_url(WC()->plugin_url()); ?> /assets/images/help.png" height="16" width="16" /> </p> <?php // Status Action Icon $action_icon = $status->get_action_icon(); $action_icon_attachment_src = ''; if (is_numeric($action_icon)) { $action_icon_attachment_src = wp_get_attachment_image_src($action_icon, 'wc_order_status_icon'); } ?> <p class="form-field _action_icon_field"> <label for="_action_icon"><?php _e('Action Icon', WC_Order_Status_Manager::TEXT_DOMAIN); ?> </label> <input type="text" id="_action_icon" name="_action_icon" class="short" value="<?php echo esc_attr($status->get_action_icon()); ?> " data-icon-image="<?php echo esc_attr($action_icon_attachment_src ? $action_icon_attachment_src[0] : ''); ?> "> <a href="#_action_icon" class="button upload-icon upload-icon-image" data-uploader-button-text="<?php _e('Set as status icon', WC_Order_Status_Manager::TEXT_DOMAIN); ?> "><?php _e("Select File", WC_Order_Status_Manager::TEXT_DOMAIN); ?> </a> <img class="help_tip" data-tip="<?php _e("Optional action icon displayed in the action buttons for the next statuses.", WC_Order_Status_Manager::TEXT_DOMAIN); ?> " src="<?php echo esc_url(WC()->plugin_url()); ?> /assets/images/help.png" height="16" width="16" /> </p> </div><!-- // .options_group --> <div class="options_group"> <?php // Next statuses $next_status_options = array(); $selected = $status->get_next_statuses(); $selected = $selected ? $selected : array(); foreach (wc_get_order_statuses() as $slug => $name) { if ($status->get_slug(true) !== $slug) { $next_status_options[str_replace('wc-', '', $slug)] = $name; } } ?> <p class="form-field _next_statuses_field"> <label for="_next_statuses"><?php _e('Next Statuses', WC_Order_Status_Manager::TEXT_DOMAIN); ?> </label> <select id="_next_statuses" name="_next_statuses[]" class="select short" multiple> <?php foreach ($next_status_options as $slug => $name) { ?> <option value="<?php echo esc_attr($slug); ?> " <?php selected(in_array($slug, $selected), 1); ?> ><?php echo esc_html($name); ?> </option> <?php } ?> </select> <img class="help_tip" data-tip="<?php _e('Zero or more statuses that would be considered next during normal order status flow. Action buttons will be available to move an order with this custom status to these next statuses.', WC_Order_Status_Manager::TEXT_DOMAIN); ?> " src="<?php echo esc_url(WC()->plugin_url()); ?> /assets/images/help.png" height="16" width="16" /> </p> <?php // Bulk action woocommerce_wp_checkbox(array('id' => '_bulk_action', 'label' => __('Bulk action', WC_Order_Status_Manager::TEXT_DOMAIN), 'description' => __('Check this to add this order status to the Orders list table Bulk Actions list.', WC_Order_Status_Manager::TEXT_DOMAIN))); // Include in reports woocommerce_wp_checkbox(array('id' => '_include_in_reports', 'label' => __('Include in reports', WC_Order_Status_Manager::TEXT_DOMAIN), 'description' => __('Check this to include orders with this order status in the order reports.', WC_Order_Status_Manager::TEXT_DOMAIN), 'value' => 'auto-draft' === $post->post_status ? 'yes' : get_post_meta($post->ID, '_include_in_reports', true))); ?> </div><!-- // .options_group --> </div><!-- // .woocommerce_options_panel --> <?php }
/** * Print styles for custom order status icons * * @since 1.0.0 */ public function custom_order_status_icons() { $custom_status_colors = array(); $custom_status_badges = array(); $custom_status_icons = array(); $custom_action_icons = array(); foreach (wc_get_order_statuses() as $slug => $name) { $status = new WC_Order_Status_Manager_Order_Status($slug); // Sanity check: bail if no status was found. // This can happen if some statuses are registered late if (!$status || !$status->get_id()) { continue; } $color = $status->get_color(); $icon = $status->get_icon(); $action_icon = $status->get_action_icon(); if ($color) { $custom_status_colors[esc_attr($status->get_slug())] = $color; } // Font icon if ($icon && ($icon_details = wc_order_status_manager()->icons->get_icon_details($icon))) { $custom_status_icons[esc_attr($status->get_slug())] = $icon_details; } elseif (is_numeric($icon) && ($icon_src = wp_get_attachment_image_src($icon, 'wc_order_status_icon'))) { $custom_status_icons[esc_attr($status->get_slug())] = $icon_src[0]; } elseif (!$icon) { $custom_status_badges[] = esc_attr($status->get_slug()); } // Font action icon if ($action_icon && ($action_icon_details = wc_order_status_manager()->icons->get_icon_details($action_icon))) { $custom_action_icons[esc_attr($status->get_slug())] = $action_icon_details; } elseif (is_numeric($action_icon) && ($action_icon_src = wp_get_attachment_image_src($action_icon, 'wc_order_status_icon'))) { $custom_action_icons[esc_attr($status->get_slug())] = $action_icon_src[0]; } } ?> <!-- Custom Order Status Icon styles --> <style type="text/css"> /*<![CDATA[*/ <?php // General styles for status badges ?> <?php if (!empty($custom_status_badges)) { ?> .widefat .column-order_status mark.<?php echo implode(', .widefat .column-order_status mark.', $custom_status_badges); ?> { display: inline-block; font-size: 0.8em; line-height: 1.1; text-indent: 0; background-color: #666; width: auto; height: auto; padding: 0.4em; color: #fff; border-radius: 2px; word-wrap: break-word; max-width: 100%; } .widefat .column-order_status mark.<?php echo implode(':after, .widefat .column-order_status mark.', $custom_status_badges); ?> :after { display: none; } <?php } ?> <?php // General styles for status icons ?> <?php if (!empty($custom_status_icons)) { ?> <?php $custom_status_font_icons = array_filter($custom_status_icons, 'is_array'); ?> <?php if (!empty($custom_status_font_icons)) { ?> .widefat .column-order_status mark.<?php echo implode(':after, .widefat .column-order_status mark.', array_keys($custom_status_font_icons)); ?> :after { speak: none; font-weight: normal; font-variant: normal; text-transform: none; line-height: 1; -webkit-font-smoothing: antialiased; margin: 0; text-indent: 0; position: absolute; top: 0; left: 0; width: 100%; height: 100%; text-align: center; } <?php } ?> <?php } ?> <?php // General styles for action icons ?> .widefat .column-order_actions a.button { padding: 0 0.5em; height: 2em; line-height: 1.9em; } <?php if (!empty($custom_action_icons)) { ?> <?php $custom_action_font_icons = array_filter($custom_action_icons, 'is_array'); ?> <?php if (!empty($custom_action_font_icons)) { ?> .order_actions .<?php echo implode(', .order_actions .', array_keys($custom_action_icons)); ?> { display: block; text-indent: -9999px; position: relative; padding: 0!important; height: 2em!important; width: 2em; } .order_actions .<?php echo implode(':after, .order_actions .', array_keys($custom_action_icons)); ?> :after { speak: none; font-weight: 400; font-variant: normal; text-transform: none; -webkit-font-smoothing: antialiased; margin: 0; text-indent: 0; position: absolute; top: 0; left: 0; width: 100%; height: 100%; text-align: center; line-height: 1.85; } <?php } ?> <?php } ?> <?php // Specific status icon styles ?> <?php if (!empty($custom_status_icons)) { ?> <?php foreach ($custom_status_icons as $status => $value) { ?> <?php if (is_array($value)) { ?> .widefat .column-order_status mark.<?php echo $status; ?> :after { font-family: "<?php echo $value['font']; ?> "; content: "<?php echo $value['glyph']; ?> "; } <?php } else { ?> .widefat .column-order_status mark.<?php echo $status; ?> { background-size: 100% 100%; background-image: url( <?php echo $value; ?> ); } <?php } ?> <?php } ?> <?php } ?> <?php // Specific status color styles ?> <?php if (!empty($custom_status_colors)) { ?> <?php foreach ($custom_status_colors as $status => $color) { ?> <?php if (in_array($status, $custom_status_badges)) { ?> .widefat .column-order_status mark.<?php echo $status; ?> { background-color: <?php echo $color; ?> ; color: <?php echo wc_order_status_manager()->icons->get_contrast_text_color($color); ?> ; } <?php } ?> <?php if (isset($custom_status_icons[$status])) { ?> .widefat .column-order_status mark.<?php echo $status; ?> :after { color: <?php echo $color; ?> ; } <?php } ?> <?php } ?> <?php } ?> <?php // Specific action icon styles ?> <?php if (!empty($custom_action_icons)) { ?> <?php foreach ($custom_action_icons as $status => $value) { ?> <?php if (is_array($value)) { ?> .order_actions .<?php echo $status; ?> :after { font-family: "<?php echo $value['font']; ?> "; content: "<?php echo $value['glyph']; ?> "; } <?php } else { ?> .order_actions .<?php echo $status; ?> , .order_actions .<?php echo $status; ?> :focus, .order_actions .<?php echo $status; ?> :hover { background-size: 69% 69%; background-position: center center; background-repeat: no-repeat; background-image: url( <?php echo $value; ?> ); } <?php } ?> <?php } ?> <?php } ?> /*]]>*/ </style> <?php }