Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 68 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| zeroBSCRM_SubmitMetaboxSetup | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| zeroBS__SubmitMetabox | |
0.00% |
0 / 65 |
|
0.00% |
0 / 3 |
272 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| initMetaBox | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |||
| print_meta_box | |
0.00% |
0 / 47 |
|
0.00% |
0 / 1 |
156 | |||
| 1 | <?php |
| 2 | /* |
| 3 | * Jetpack CRM |
| 4 | * https://jetpackcrm.com |
| 5 | * V1.1.19 |
| 6 | * |
| 7 | * Copyright 2020 Automattic |
| 8 | * |
| 9 | * Date: 25/10/16 |
| 10 | */ |
| 11 | |
| 12 | defined( 'ZEROBSCRM_PATH' ) || exit( 0 ); |
| 13 | |
| 14 | # NOTE: http://themeflection.com/replace-wordpress-submit-meta-box/ |
| 15 | |
| 16 | /* |
| 17 | ====================================================== |
| 18 | Init Func |
| 19 | ====================================================== */ |
| 20 | |
| 21 | function zeroBSCRM_SubmitMetaboxSetup() { |
| 22 | |
| 23 | $zeroBS__SubmitMetabox = new zeroBS__SubmitMetabox( __FILE__ ); |
| 24 | } |
| 25 | |
| 26 | add_action( 'admin_init', 'zeroBSCRM_SubmitMetaboxSetup' ); |
| 27 | |
| 28 | /* |
| 29 | ====================================================== |
| 30 | / Init Func |
| 31 | ====================================================== */ |
| 32 | |
| 33 | /* |
| 34 | ====================================================== |
| 35 | Submit Metabox |
| 36 | ====================================================== */ |
| 37 | |
| 38 | class zeroBS__SubmitMetabox { |
| 39 | |
| 40 | static $instance; |
| 41 | #private $packPerm; |
| 42 | #private $pack; |
| 43 | private $postTypes; |
| 44 | private $postTypesLabels; |
| 45 | |
| 46 | public function __construct( $plugin_file ) { |
| 47 | # if ( $this->instance instanceof wProject_Metabox ) { |
| 48 | # wp_die( sprintf( __( 'Cannot instantiate singleton class: %1$s. Use %1$s::$instance instead.', 'zero-bs-crm' ), __CLASS__ ) ); |
| 49 | #} else { |
| 50 | self::$instance = $this; |
| 51 | #} |
| 52 | |
| 53 | #$this->postType = 'zerobs_customer'; |
| 54 | #add_action( 'add_meta_boxes', array( $this, 'create_meta_box' ) ); |
| 55 | #} Moved to multiples 1.1.19 WH |
| 56 | |
| 57 | $this->postTypes = array( 'zerobs_invoice' ); |
| 58 | #} Temp |
| 59 | $this->postTypesLabels = array( |
| 60 | 'zerobs_invoice' => 'Invoice', |
| 61 | ); |
| 62 | add_action( 'add_meta_boxes', array( $this, 'initMetaBox' ) ); |
| 63 | |
| 64 | #add_filter( 'save_post', array( $this, 'save_meta_box' ), 10, 2 ); |
| 65 | } |
| 66 | |
| 67 | public function initMetaBox() { |
| 68 | |
| 69 | if ( count( $this->postTypes ) > 0 ) { |
| 70 | foreach ( $this->postTypes as $pt ) { |
| 71 | |
| 72 | #} pass an arr |
| 73 | $callBackArr = array( $this, $pt ); |
| 74 | |
| 75 | add_meta_box( |
| 76 | 'wpzbscsub_itemdetails_' . $pt, |
| 77 | __( $this->postTypesLabels[ $pt ], 'zero-bs-crm' ) . ' Actions', #quick title |
| 78 | array( $this, 'print_meta_box' ), |
| 79 | $pt, |
| 80 | 'side', |
| 81 | 'low', |
| 82 | $callBackArr |
| 83 | ); |
| 84 | |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | /* |
| 89 | public function create_meta_box() { |
| 90 | |
| 91 | |
| 92 | #} Don't share for new customers :) |
| 93 | #if (isset($this->ID)){ |
| 94 | |
| 95 | add_meta_box( |
| 96 | 'wpzbscext_itemdetails', |
| 97 | 'External Source(s)', |
| 98 | array( $this, 'print_meta_box' ), |
| 99 | $this->postType, |
| 100 | 'side', |
| 101 | 'low' |
| 102 | ); |
| 103 | |
| 104 | #} |
| 105 | } |
| 106 | */ |
| 107 | public function print_meta_box( $post, $metabox ) { |
| 108 | |
| 109 | #} Post type |
| 110 | $postType = ''; |
| 111 | if ( isset( $metabox['args'] ) && isset( $metabox['args'][1] ) && ! empty( $metabox['args'][1] ) ) { |
| 112 | $postType = $metabox['args'][1]; |
| 113 | } |
| 114 | |
| 115 | #} Only load if is legit. |
| 116 | if ( in_array( $postType, array( 'zerobs_invoice' ) ) ) { |
| 117 | |
| 118 | #} if a saved post... |
| 119 | if ( isset( $post->post_status ) && $post->post_status != 'auto-draft' ) { |
| 120 | ?> |
| 121 | <input type="hidden" name="meta_box_ids[]" value="<?php echo esc_attr( $metabox['id'] ); ?>" /> |
| 122 | |
| 123 | |
| 124 | <?php |
| 125 | $zbs_inv_meta = get_post_meta( $post->ID, 'zbs_customer_invoice_meta', true ); |
| 126 | |
| 127 | if ( ! isset( $zbs_inv_meta['status'] ) ) { |
| 128 | $zbs_stat = 'Draft'; |
| 129 | } else { |
| 130 | $zbs_stat = $zbs_inv_meta['status']; |
| 131 | } |
| 132 | |
| 133 | global $zbsCustomerInvoiceFields; |
| 134 | |
| 135 | $sel = ''; |
| 136 | ?> |
| 137 | <div class="zbs-actions-side"> |
| 138 | <div class="row"> |
| 139 | <div class='pull-left zbs-what'> |
| 140 | <?php esc_html_e( 'Status', 'zero-bs-crm' ); ?> |
| 141 | </div> |
| 142 | <div class="action pull-right"> |
| 143 | <select id="invoice_status" name="invoice_status"> |
| 144 | <?php |
| 145 | foreach ( $zbsCustomerInvoiceFields['status'][3] as $z ) { |
| 146 | if ( $z == $zbs_stat ) { |
| 147 | $sel = 'selected'; |
| 148 | } else { |
| 149 | $sel = '';} |
| 150 | echo '<option value="' . esc_attr( $z ) . '"' . esc_attr( $sel ) . '>' . esc_html__( $z, 'zero-bs-crm' ) . '</option>'; |
| 151 | } |
| 152 | ?> |
| 153 | </select> |
| 154 | </div> |
| 155 | </div> |
| 156 | </div> |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | <div class="clear"></div> |
| 163 | |
| 164 | <?php do_action( 'zbs_invpro_itemlink' ); ?> |
| 165 | |
| 166 | <div class="clear"></div> |
| 167 | |
| 168 | |
| 169 | <div class='bottom zbs-invoice-actions-bottom'> |
| 170 | <button class='button button-primary button-large pull-right' id="zbs_invoice_save"><?php esc_attr_e( 'Update', 'zero-bs-crm' ); ?></button> |
| 171 | <?php |
| 172 | |
| 173 | #} Quick ver of this: http://themeflection.com/replace-wordpress-submit-meta-box/ |
| 174 | |
| 175 | ?> |
| 176 | <div id="delete-action" class='pull-left'> |
| 177 | <?php |
| 178 | if ( current_user_can( 'delete_post', $post->ID ) ) { |
| 179 | if ( ! EMPTY_TRASH_DAYS ) { |
| 180 | $delete_text = __( 'Delete Permanently', 'zero-bs-crm' ); |
| 181 | } else { |
| 182 | $delete_text = __( 'Move to Trash', 'zero-bs-crm' ); |
| 183 | } |
| 184 | ?> |
| 185 | <a class="submitdelete deletion" href="<?php echo get_delete_post_link( $post->ID ); ?>"><?php echo esc_html( $delete_text ); ?></a> |
| 186 | <?php |
| 187 | } //if |
| 188 | ?> |
| 189 | </div> |
| 190 | <div class='clear'></div> |
| 191 | </div> |
| 192 | <?php |
| 193 | |
| 194 | } else { |
| 195 | |
| 196 | ?> |
| 197 | |
| 198 | <?php do_action( 'zbs_invpro_itemlink' ); ?> |
| 199 | |
| 200 | <button class='button button-primary button-large' id="zbs_invoice_save"><?php esc_html_e( 'Save', 'zero-bs-crm' ); ?></button> |
| 201 | |
| 202 | <?php |
| 203 | |
| 204 | #} If it's a new post |
| 205 | |
| 206 | #} Gross hide :/ |
| 207 | |
| 208 | } |
| 209 | } // / only load if post type |
| 210 | } |
| 211 | |
| 212 | /* |
| 213 | not req public function save_meta_box( $post_id, $post ) { |
| 214 | if( empty( $_POST['meta_box_ids'] ) ){ return; } |
| 215 | foreach( $_POST['meta_box_ids'] as $metabox_id ){ |
| 216 | if( ! wp_verify_nonce( $_POST[ $metabox_id . '_nonce' ], 'save_' . $metabox_id ) ){ continue; } |
| 217 | #if( count( $_POST[ $metabox_id . '_fields' ] ) == 0 ){ continue; } |
| 218 | if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ continue; } |
| 219 | |
| 220 | if( $metabox_id == 'wpzbscext_itemdetails' && $post->post_type == $this->postType){ |
| 221 | |
| 222 | #} Nothing needed |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | return $post; |
| 227 | } */ |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * End of Submit Metabox |
| 232 | */ |