*/ require_once('metaboxes-product_data.php'); /** * Init the meta boxes * * Inits the write panels for both products and orders. Also removes unused default write panels. */ add_action( 'add_meta_boxes', 'apptivo_ecommerce_meta_boxes' ); function apptivo_ecommerce_meta_boxes() { // Post Excerpt if ( function_exists('wp_editor') ) { remove_meta_box( 'postexcerpt', 'product', 'normal' ); add_meta_box( 'postexcerpt','Product Short Description', 'apptivo_ecommerce_item_short_description_meta_box', 'item', 'normal' ); } add_meta_box( 'apptivo_ecommerce-item-data', __('Product Visibility & Data', 'apptivo_ecommerce'), 'apptivo_ecommerce_product_data_box', 'item', 'normal', 'high' ); } function apptivo_ecommerce_item_short_description_meta_box( $post ) { $settings = array( 'quicktags' => array( 'buttons' => 'em,strong,link' ), 'textarea_name' => 'excerpt', 'quicktags' => true, 'tinymce' => true, 'editor_css' => '' ); wp_editor( htmlspecialchars_decode( $post->post_excerpt ), 'excerpt', $settings ); global $apptivo_ecommerce; ?> post_type != 'item' ) return $post_id; do_action( 'apptivo_ecommerce_process_'.$post->post_type.'_meta', $post_id, $post ); } /** * Save Errors */ add_action( 'admin_notices', 'apptivo_ecommerce_meta_boxes_save_errors' ); function apptivo_ecommerce_meta_boxes_save_errors() { $apptivo_ecommerce_errors = maybe_unserialize(get_option('apptivo_ecommerce_errors')); if ($apptivo_ecommerce_errors && sizeof($apptivo_ecommerce_errors)>0) : echo '
'; foreach ($apptivo_ecommerce_errors as $error) : echo '

'.$error.'

'; endforeach; echo '
'; update_option('apptivo_ecommerce_errors', ''); endif; } /** * Output write panel form elements */ function apptivo_ecommerce_wp_text_input( $field ) { global $thepostid, $post; if (!$thepostid) $thepostid = $post->ID; if (!isset($field['placeholder'])) $field['placeholder'] = ''; if (!isset($field['class'])) $field['class'] = 'short'; if (!isset($field['value'])) $field['value'] = get_post_meta($thepostid, $field['id'], true); if( $field['value'] == '' ){ if( $field['id'] == '_apptivo_item_code' ){ $field['value'] = $thepostid; } } echo '

'.$field['notes']; if (isset($field['description'])) echo '' .$field['description'] . ''; echo '

'; } function apptivo_ecommerce_wp_select_suppliers( $field ) { global $thepostid, $post; if (!$thepostid) $thepostid = $post->ID; if (!isset($field['class'])) $field['class'] = 'select short'; if (!isset($field['value'])) $field['value'] = get_post_meta($thepostid,'_apptivo_supplier', true); $apptivo_suppliers = app_convertObjectToArray(getSupliers()->return->supplierList); echo '

'; if (isset($field['description'])) echo '' .$field['description'] . ''; echo '

'; } function apptivo_ecommerce_wp_checkbox( $field ) { global $thepostid, $post; if (!$thepostid) $thepostid = $post->ID; if (!isset($field['class'])) $field['class'] = 'checkbox'; if (!isset($field['value'])) $field['value'] = get_post_meta($thepostid, $field['id'], true); echo '

'; if (isset($field['description'])) echo '' .$field['description'] . ''; echo '

'; }