PluginProbe
Welcart e-Commerce / 1.3.8
Welcart e-Commerce v1.3.8
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / includes / edit-form-advanced.php

edit-form-advanced.php in Welcart e-Commerce 1.3.8, at includes/edit-form-advanced.php

902 lines 38.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Post advanced form for inclusion in the administration panels.
4 *
5 * @package WordPress
6 * @subpackage Welcart
7 */
8
9 /**
10 * Post ID global
11 * @name $post_ID
12 * @var int
13 */
14 $post_ID = isset($post_ID) ? (int) $post_ID : 0;
15
16 $action = isset($action) ? $action : '';
17
18 if ( isset($_GET['message']) )
19 $_GET['message'] = absint( $_GET['message'] );
20 $messages[1] = sprintf(__('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID));
21 $messages[2] = __('Custom field updated.');
22 $messages[3] = __('Custom field deleted.');
23 $messages[4] = __('Post updated.');
24 $messages[6] = sprintf(__('Post published. <a href="%s">View post</a>'), get_permalink($post_ID));
25 $messages[7] = __('Post saved.');
26 $messages[8] = sprintf(__('Post submitted. <a href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
27
28 if ( isset($_GET['revision']) )
29 $messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) );
30
31 $notice = false;
32 $notices[1] = __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>.' );
33
34 if ( 0 == $post_ID ) {
35 $form_action = 'post';
36 $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post()
37 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='" . esc_attr($temp_ID) . "' />";
38 $autosave = false;
39 } else {
40 $form_action = 'editpost';
41 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
42 $autosave = wp_get_post_autosave( $post_ID );
43
44 // Detect if there exists an autosave newer than the post and if that autosave is different than the post
45 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
46 foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
47 if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
48 $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
49 break;
50 }
51 }
52 unset($autosave_field, $_autosave_field);
53 }
54 }
55
56 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
57
58 /**
59 * Display post submit form fields.
60 *
61 * @since 2.7.0
62 *
63 * @param object $post
64 */
65 function post_submit_meta_box($post) {
66 global $action;
67
68 $can_publish = current_user_can('publish_posts');
69 ?>
70 <div class="submitbox" id="submitpost">
71
72 <div id="minor-publishing">
73
74 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
75 <div style="display:none;">
76 <input type="submit" name="save" value="<?php esc_attr_e('Save'); ?>" />
77 </div>
78
79 <div id="minor-publishing-actions">
80 <div id="save-action">
81 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
82 <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" tabindex="4" class="button button-highlighted" />
83 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
84 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" />
85 <?php } ?>
86 </div>
87
88 <div id="preview-action">
89 <?php
90 //if ( 'publish' == $post->post_status ) {
91 // $preview_link = esc_url(get_permalink($post->ID));
92 // $preview_button = __('Preview Changes');
93 //} else {
94 $preview_link = esc_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID))));
95 $preview_button = __('Preview');
96 //}
97 ?>
98 <a class="preview button" href="<?php echo $preview_link; ?>" target="_blank" id="preview" tabindex="4"><?php echo $preview_button; ?></a>
99 <input type="hidden" name="wp-preview" id="wp-preview" value="" />
100 </div>
101
102 <div class="clear"></div>
103 </div><?php // /minor-publishing-actions ?>
104
105 <div id="misc-publishing-actions">
106 <div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label>
107 <span id="post-status-display">
108 <?php
109 switch ( $post->post_status ) {
110 case 'private':
111 _e('Privately Published');
112 break;
113 case 'publish':
114 _e('Published');
115 break;
116 case 'future':
117 _e('Scheduled');
118 break;
119 case 'pending':
120 _e('Pending Review');
121 break;
122 case 'draft':
123 _e('Draft');
124 break;
125 }
126 ?>
127 </span>
128 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
129 <a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
130
131 <div id="post-status-select" class="hide-if-js">
132 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr($post->post_status); ?>" />
133 <select name='post_status' id='post_status' tabindex='4'>
134 <?php if ( 'publish' == $post->post_status ) : ?>
135 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
136 <?php elseif ( 'private' == $post->post_status ) : ?>
137 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
138 <?php elseif ( 'future' == $post->post_status ) : ?>
139 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
140 <?php endif; ?>
141 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
142 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
143 </select>
144 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
145 <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
146 </div>
147
148 <?php } ?>
149 </div><?php // /misc-pub-section ?>
150
151 <div class="misc-pub-section " id="visibility">
152 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
153
154 if ( 'private' == $post->post_status ) {
155 $post->post_password = '';
156 $visibility = 'private';
157 $visibility_trans = __('Private');
158 } elseif ( !empty( $post->post_password ) ) {
159 $visibility = 'password';
160 $visibility_trans = __('Password protected');
161 } elseif ( is_sticky( $post->ID ) ) {
162 $visibility = 'public';
163 $visibility_trans = __('Public, Sticky');
164 } else {
165 $visibility = 'public';
166 $visibility_trans = __('Public');
167 }
168
169 ?><?php echo esc_html( $visibility_trans ); ?></span> <?php if ( $can_publish ) { ?> <a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
170
171 <div id="post-visibility-select" class="hide-if-js">
172 <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
173 <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
174 <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
175
176
177 <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
178 <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label><br /></span>
179 <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
180 <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span>
181 <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
182
183 <p>
184 <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
185 <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
186 </p>
187 </div>
188 <?php } ?>
189
190 </div><?php // /misc-pub-section ?>
191
192
193 <?php
194 // translators: Publish box date formt, see http://php.net/date
195 $datef = __( 'M j, Y @ G:i' );
196 if ( 0 != $post->ID ) {
197 if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
198 $stamp = __('Scheduled for: <b>%1$s</b>');
199 } else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
200 $stamp = __('Published on: <b>%1$s</b>');
201 } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
202 $stamp = __('Publish <b>immediately</b>');
203 } else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
204 $stamp = __('Schedule for: <b>%1$s</b>');
205 } else { // draft, 1 or more saves, date specified
206 $stamp = __('Publish on: <b>%1$s</b>');
207 }
208 $date = date_i18n( $datef, strtotime( $post->post_date ) );
209 } else { // draft (no saves, and thus no date specified)
210 $stamp = __('Publish <b>immediately</b>');
211 $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
212 }
213
214 if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
215 <div class="misc-pub-section curtime misc-pub-section-last">
216 <span id="timestamp">
217 <?php printf($stamp, $date); ?></span>
218 <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
219 <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>
220 </div><?php // /misc-pub-section ?>
221 <?php endif; ?>
222
223 <?php do_action('post_submitbox_misc_actions'); ?>
224 </div>
225 <div class="clear"></div>
226 </div>
227
228 <div id="major-publishing-actions">
229 <?php do_action('post_submitbox_start'); ?>
230 <div id="delete-action">
231 <?php
232 if ( ( 'edit' == $action ) && current_user_can('delete_post', $post->ID) ) { ?>
233 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete Permanently'); ?></a>
234 <?php } ?>
235 </div>
236
237 <div id="publishing-action">
238 <?php
239 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) {
240 if ( current_user_can('publish_posts') ) :
241 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
242 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" />
243 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Schedule') ?>" />
244 <?php else : ?>
245 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
246 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Publish') ?>" />
247 <?php endif;
248 else : ?>
249 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
250 <input name="publish" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Submit for Review') ?>" />
251 <?php
252 endif;
253 } else { ?>
254 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update Post') ?>" />
255 <input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Update Post') ?>" />
256 <?php
257 } ?>
258 </div>
259 <div class="clear"></div>
260 </div>
261 </div>
262
263 <?php
264 }
265 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', 'post', 'side', 'core');
266
267
268 /**
269 * Display post tags form fields.
270 *
271 * @since 2.6.0
272 *
273 * @param object $post
274 */
275 function post_tags_meta_box($post, $box) {
276 $tax_name = esc_attr(substr($box['id'], 8));
277 $taxonomy = get_taxonomy($tax_name);
278 $helps = isset($taxonomy->helps) ? esc_attr($taxonomy->helps) : __('Separate tags with commas');
279 ?>
280 <div class="tagsdiv" id="<?php echo $tax_name; ?>">
281 <div class="jaxtag">
282 <div class="nojs-tags hide-if-js">
283 <p><?php _e('Add or remove tags'); ?></p>
284 <textarea name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]"><?php echo esc_attr(get_terms_to_edit( $post->ID, $tax_name )); ?></textarea></div>
285
286 <div class="ajaxtag hide-if-no-js">
287 <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
288 <div class="taghint"><?php _e('Add new tag'); ?></div>
289 <input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
290 <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
291 </div></div>
292 <p class="howto"><?php echo $helps; ?></p>
293 <div class="tagchecklist"></div>
294 </div>
295 <p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php printf( __('Choose from the most used tags in %s'), $box['title'] ); ?></a></p>
296 <?php
297 }
298
299 // all tag-style post taxonomies
300 foreach ( get_object_taxonomies('post') as $tax_name ) {
301 if ( !is_taxonomy_hierarchical($tax_name) ) {
302 $taxonomy = get_taxonomy($tax_name);
303 $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name;
304
305 add_meta_box('tagsdiv-' . $tax_name, __('tag', 'usces'), 'post_tags_meta_box', 'post', 'side', 'core');
306 }
307 }
308
309
310
311
312 function post_item_pict_box($post) {
313 global $wpdb;
314 $custom_fields = get_post_custom($post->ID);
315 if(!$custom_fields){
316 $item_picts[0] = wp_get_attachment_image( NULL, array(260, 200), true );
317 }else{
318 $item_code = $custom_fields['_itemCode'][0];
319 $codestr = $item_code . '%';
320 $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title LIKE %s AND post_type = 'attachment' ORDER BY post_title", $codestr);
321 $item_pictids = $wpdb->get_col( $query );
322 for($i=0; $i<count($item_pictids); $i++){
323 $item_picts[] = wp_get_attachment_image( $item_pictids[$i], array(260, 200), true );
324 $item_sumnails[] = wp_get_attachment_image( $item_pictids[$i], array(50, 50), true );
325 }
326 }
327 ?>
328 <div class="item-main-pict">
329 <div id="item-select-pict">
330 <?php
331 if($item_sumnails) {
332 echo $item_picts[0];
333 } else {
334 ?>
335 <!--<img src="#" width="260" height="200" alt="" />-->
336
337 <?php
338 }
339 ?>
340 </div>
341 <div class="clearfix">
342 <?php for($i=0; $i<count($item_sumnails); $i++){ ?>
343 <div class="subpict"><a onclick='uscesItem.cahngepict("<?php echo str_replace('"', '\"', $item_picts[$i]); ?>");'><?php echo $item_sumnails[$i]; ?></a></div>
344 <?php } ?>
345 </div>
346 </div>
347 <?php
348 }
349 add_meta_box('item-main-pict', __('Item image', 'usces'), 'post_item_pict_box', 'post', 'side', 'high');
350
351 /**
352 * Display post categories form fields.[cartegory]side core
353 *
354 * @since 2.6.0
355 *
356 * @param object $post
357 */
358 function post_categories_meta_box($post) {
359 ?>
360 <ul id="category-tabs">
361 <li class="tabs"><a href="#categories-all" tabindex="3"><?php _e('The hierarchy category of the item', 'usces'); ?></a></li>
362 <!--<li class="hide-if-no-js"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>-->
363 </ul>
364
365 <!--<div id="categories-pop" class="tabs-panel" style="display: none;">
366 <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
367 <?php $popular_ids = wp_popular_terms_checklist('category'); ?>
368 </ul>
369 </div>-->
370
371 <div id="categories-all" class="tabs-panel">
372 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
373 <?php wp_category_checklist($post->ID, USCES_ITEM_CAT_PARENT_ID, false, false, NULL, false) ?>
374 </ul>
375 </div>
376
377 <?php if ( current_user_can('manage_categories') ) : ?>
378 <!--<div id="category-adder" class="wp-hidden-children">
379 <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
380 <p id="category-add" class="wp-hidden-child">
381 <label class="screen-reader-text" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
382 <label class="screen-reader-text" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category') ) ); ?>
383 <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" />
384 <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
385 <span id="category-ajax-response"></span></p>
386 </div>-->
387 <?php
388 endif;
389
390 }
391
392
393 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
394
395 /**
396 * Display post password form fields.
397 *
398 * @since 2.6.0
399 *
400 * @param object $post
401 */
402 function post_password_meta_box($post) {
403 ?>
404 <p>
405 <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> tabindex="4" /> <?php _e('Keep this post private') ?></label>
406 </p>
407 <h4><?php _e( 'Post Password' ); ?></h4>
408 <p><label class="hidden" for="post_password"><?php _e('Password Protect This Post') ?></label><input name="post_password" type="text" size="25" id="post_password" value="<?php the_post_password(); ?>" /></p>
409 <p><?php _e('Setting a password will require people who visit your blog to enter the above password to view this post and its comments.'); ?></p>
410 <?php
411 }
412 // add_meta_box('passworddiv', __('Privacy Options'), 'post_password_meta_box', 'post', 'side', 'core');
413
414 /**
415 * Display post excerpt form fields.[excerpt]normal core
416 *
417 * @since 2.6.0
418 *
419 * @param object $post
420 */
421 function post_excerpt_meta_box($post) {
422 ?>
423 <label class="screen-reader-text" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea>
424 <p><?php _e('This excerpt is a summary of the product description.', 'usces'); ?></p>
425 <?php
426 }
427 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
428
429 /**
430 * Display trackback links form fields.[trackback]normal core
431 *
432 * @since 2.6.0
433 *
434 * @param object $post
435 */
436 function post_trackback_meta_box($post) {
437 $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />';
438 if ('' != $post->pinged) {
439 $pings = '<p>'. __('Already pinged:') . '</p><ul>';
440 $already_pinged = explode("\n", trim($post->pinged));
441 foreach ($already_pinged as $pinged_url) {
442 $pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>";
443 }
444 $pings .= '</ul>';
445 }
446
447 ?>
448 <p><label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
449 <p><?php _e('Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress blogs they&#8217;ll be notified automatically using <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p>
450 <?php
451 if ( ! empty($pings) )
452 echo $pings;
453 }
454 //add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core');
455
456 /**
457 * Display custom fields for the post form fields.[custom fields]normal core
458 *
459 * @since 2.6.0
460 *
461 * @param object $post
462 */
463 function post_custom_meta_box($post) {
464 ?>
465 <div id="postcustomstuff">
466 <div id="ajax-response"></div>
467 <?php
468 $metadata = has_meta($post->ID);
469 list_meta($metadata);
470 meta_form(); ?>
471 </div>
472 <p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
473 <?php
474 }
475 //add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core');
476
477 do_action('dbx_post_advanced');
478
479 /**
480 * Display comment status for post form fields.[comment]normal core
481 *
482 * @since 2.6.0
483 *
484 * @param object $post
485 */
486 function post_comment_status_meta_box($post) {
487 global $wpdb, $post_ID;
488 ?>
489 <input name="advanced_view" type="hidden" value="1" />
490 <p class="meta-options">
491 <label for="comment_status" class="selectit"> <input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e('Allow comments on this post') ?></label><br />
492 <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">trackbacks and pingbacks</a> on this post') ?></label>
493 </p>
494 <?php
495 $total = $wpdb->get_var($wpdb->prepare("SELECT count(1) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID));
496
497 if ( !$post_ID || $post_ID < 0 || 1 > $total )
498 return;
499
500 wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
501 ?>
502
503 <table class="widefat comments-box fixed" cellspacing="0" style="display:none;">
504 <thead>
505 <tr>
506 <th scope="col" class="column-author"><?php _e('Author') ?></th>
507 <th scope="col" class="column-comment"><?php echo _x('Comment','noun') ?></th>
508 </tr>
509 </thead>
510 <tbody id="the-comment-list" class="list:comment">
511 </tbody>
512 </table>
513 <p class="hide-if-no-js"><a href="#commentstatusdiv" id="show-comments" onclick="commentsBox.get(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="images/loading.gif" alt="" /></p>
514 <?php
515 $hidden = get_hidden_meta_boxes('post');
516 if ( ! in_array('commentstatusdiv', $hidden) ) { ?>
517 <script type="text/javascript">commentsBox.get(<?php echo $total; ?>, 10);</script>
518 <?php
519 }
520 }
521 //add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'post', 'normal', 'core');
522
523 /**
524 * Display post slug form fields.
525 *
526 * @since 2.6.0
527 *
528 * @param object $post
529 */
530 function post_slug_meta_box($post) {
531 ?>
532 <label class="hidden" for="post_name"><?php _e('Post Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" />
533 <?php
534 }
535 if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) )
536 add_meta_box('slugdiv', __('Post Slug'), 'post_slug_meta_box', 'post', 'normal', 'core');
537
538 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
539 if ( $post->post_author && !in_array($post->post_author, $authors) )
540 $authors[] = $post->post_author;
541 if ( $authors && count( $authors ) > 1 ) :
542 /**
543 * Display form field with list of authors.
544 *
545 * @since 2.6.0
546 *
547 * @param object $post
548 */
549 function post_author_meta_box($post) {
550 global $current_user, $user_ID;
551 $authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
552 if ( $post->post_author && !in_array($post->post_author, $authors) )
553 $authors[] = $post->post_author;
554 ?>
555 <label class="hidden" for="post_author_override"><?php _e('Post Author'); ?></label><?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author) ); ?>
556 <?php
557 }
558 //add_meta_box('authordiv', __('Post Author'), 'post_author_meta_box', 'post', 'normal', 'core');
559 endif;
560
561 if ( 0 < $post_ID && wp_get_post_revisions( $post_ID ) ) :
562 /**
563 * Display list of post revisions.
564 *
565 * @since 2.6.0
566 *
567 * @param object $post
568 */
569 function post_revisions_meta_box($post) {
570 wp_list_post_revisions();
571 }
572 //add_meta_box('revisionsdiv', __('Post Revisions'), 'post_revisions_meta_box', 'post', 'normal', 'core');
573 endif;
574
575 do_action('do_meta_boxes', 'post', 'normal', $post);
576 do_action('do_meta_boxes', 'post', 'advanced', $post);
577 do_action('do_meta_boxes', 'post', 'side', $post);
578
579 //require_once(ABSPATH . '\wp-admin\admin-header.php');
580
581 ?>
582
583 <?php if ( (isset($mode) && 'bookmarklet' == $mode) || isset($_GET['popupurl']) ): ?>
584 <input type="hidden" name="mode" value="bookmarklet" />
585 <?php endif; ?>
586
587
588
589
590
591
592
593
594
595
596
597
598 <?php
599
600 $status = $this->action_status;
601 $message = $this->action_message;
602 $this->action_status = 'none';
603 $this->action_message = '';
604
605 ?>
606 <script type="text/javascript">
607
608 jQuery(function($){
609 <?php if($status == 'success'){ ?>
610 $("#anibox").animate({ backgroundColor: "#ECFFFF" }, 2000);
611 <?php }else if($status == 'caution'){ ?>
612 $("#anibox").animate({ backgroundColor: "#FFF5CE" }, 2000);
613 <?php }else if($status == 'error'){ ?>
614 $("#anibox").animate({ backgroundColor: "#FFE6E6" }, 2000);
615 <?php } ?>
616 });
617 </script>
618
619 <div class="wrap">
620 <div class="usces_admin">
621 <h2><!--<img src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/usc-e-shop/images/easymoblog1.png" /> --><?php echo esc_html( $title ); ?></h2>
622 <div id="aniboxStatus" class="<?php echo $status; ?>">
623 <div id="anibox" class="clearfix">
624 <img src="<?php echo USCES_PLUGIN_URL; ?>/images/list_message_<?php echo $status; ?>.gif" />
625 <div class="mes" id="info_massage"><?php echo $message; ?></div>
626 </div>
627 </div>
628 <form name="post" action="" method="post" id="post">
629 <?php
630
631 if ( 0 == $post_ID)
632 wp_nonce_field('add-post');
633 else
634 wp_nonce_field('update-post_' . $post_ID);
635
636 $itemCode = get_post_meta($post_ID, '_itemCode', true);
637 $itemName = get_post_meta($post_ID, '_itemName', true);
638 $itemRestriction = get_post_meta($post_ID, '_itemRestriction', true);
639 $itemPointrate = get_post_meta($post_ID, '_itemPointrate', true);
640 $itemGpNum1 = get_post_meta($post_ID, '_itemGpNum1', true);
641 $itemGpNum2 = get_post_meta($post_ID, '_itemGpNum2', true);
642 $itemGpNum3 = get_post_meta($post_ID, '_itemGpNum3', true);
643 $itemGpDis1 = get_post_meta($post_ID, '_itemGpDis1', true);
644 $itemGpDis2 = get_post_meta($post_ID, '_itemGpDis2', true);
645 $itemGpDis3 = get_post_meta($post_ID, '_itemGpDis3', true);
646
647 $itemShipping = get_post_meta($post_ID, '_itemShipping', true);
648 $itemDeliveryMethod = get_post_meta($post_ID, '_itemDeliveryMethod', true);
649 $itemShippingCharge = get_post_meta($post_ID, '_itemShippingCharge', true);
650 $itemIndividualSCharge = get_post_meta($post_ID, '_itemIndividualSCharge', true);
651
652 ?>
653 <input type="hidden" name="usces_nonce" id="usces_nonce" value="<?php echo wp_create_nonce( 'usc-e-shop' ); ?>" />
654 <input type="hidden" name="post_mime_type" value="item" />
655 <input type="hidden" name="page" value="usces_itemedit" />
656 <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
657 <input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
658 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
659 <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
660 <input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
661 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status; ?>" />
662 <input name="referredby" type="hidden" id="referredby" value="<?php echo clean_url(stripslashes(wp_get_referer())); ?>" />
663 <input name="usces_referer" type="hidden" id="usces_referer" value="<?php if(isset($_REQUEST['usces_referer'])) echo $_REQUEST['usces_referer']; ?>" />
664 <?php if ( 'draft' != $post->post_status ) wp_original_referer_field(true, 'previous'); ?>
665
666 <?php echo $form_extra ?>
667 <div id="refbutton"><a href="<?php echo USCES_ADMIN_URL . '?page=usces_itemedit&amp;action=duplicate&amp;post='.$post->ID.'&usces_referer='.urlencode($_REQUEST['usces_referer']); ?>">[<?php _e('make a copy', 'usces'); ?>]</a> <a href="<?php if(isset($_REQUEST['usces_referer'])) echo $_REQUEST['usces_referer']; ?>">[<?php _e('back to item list', 'usces'); ?>]</a></div>
668 <div id="poststuff" class="metabox-holder has-right-sidebar">
669
670 <div id="side-info-column" class="inner-sidebar">
671 <div id="item-main-pict">
672 </div>
673 <?php do_action('submitpost_box'); ?>
674
675 <?php $side_meta_boxes = do_meta_boxes('post', 'side', $post); ?>
676 </div>
677
678 <div id="post-body" class="<?php echo $side_meta_boxes ? 'has-sidebar' : ''; ?>">
679 <div id="post-body-content" class="has-sidebar-content">
680
681 <div id="postitemcustomstuff">
682 <table class="iteminfo_table">
683 <tr>
684 <th><?php _e('item code', 'usces'); ?></th>
685 <td><input type="text" name="itemCode" id="itemCode" class="itemCode" value="<?php echo esc_attr($itemCode); ?>" />
686 <input type="hidden" name="itemCode_nonce" id="itemCode_nonce" value="<?php echo wp_create_nonce( 'itemCode_nonce' ); ?>" /></td>
687 </tr>
688 <tr>
689 <th><?php _e('item name', 'usces'); ?></th>
690 <td><input type="text" name="itemName" id="itemName" class="itemName" value="<?php echo esc_attr($itemName); ?>" />
691 <input type="hidden" name="itemName_nonce" id="itemName_nonce" value="<?php echo wp_create_nonce( 'itemName_nonce' ); ?>" /></td>
692 </tr>
693 <tr>
694 <th><?php _e('Limited amount for purchase', 'usces'); ?></th>
695 <td><?php printf(__('limit by%s%s%s', 'usces'), '<input type="text" name="itemRestriction" id="itemRestriction" class="itemRestriction" value="', esc_attr($itemRestriction), '" />'); ?>
696 <input type="hidden" name="itemRestriction_nonce" id="itemRestriction_nonce" value="<?php echo wp_create_nonce( 'itemRestriction_nonce' ); ?>" /></td>
697 </tr>
698 <tr>
699 <th><?php _e('Percentage of points', 'usces'); ?></th>
700 <td><input type="text" name="itemPointrate" id="itemPointrate" class="itemPointrate" value="<?php echo esc_attr($itemPointrate); ?>" />%<em>(<?php _e('Integer', 'usces'); ?>)</em>
701 <input type="hidden" name="itemPointrate_nonce" id="itemPointrate_nonce" value="<?php echo wp_create_nonce( 'itemPointrate_nonce' ); ?>" /></td>
702 </tr>
703 <tr>
704 <th rowspan="3"><?php _e('Business package discount', 'usces'); ?></th>
705 <td>1.<?php printf(__('in more than%s%s%s%s%s %s%s%s,', 'usces'), '<input type="text" name="', 'itemGpNum1', '" id="', 'itemGpNum1', '" class="itemPointrate"', 'value="', esc_attr($itemGpNum1), '" />'); ?><input type="text" name="itemGpDis1" id="itemGpDis1" class="itemPointrate" value="<?php echo esc_attr($itemGpDis1); ?>" /><?php _e('%discount','usces'); ?> (<?php _e('Unit price','usces'); ?>) </td>
706 </tr>
707 <tr>
708 <td>2.<?php printf(__('in more than%s%s%s%s%s %s%s%s,', 'usces'), '<input type="text" name="', 'itemGpNum2', '" id="', 'itemGpNum2', '" class="itemPointrate"', 'value="', esc_attr($itemGpNum2), '" />'); ?><input type="text" name="itemGpDis2" id="itemGpDis2" class="itemPointrate" value="<?php echo esc_attr($itemGpDis2); ?>" /><?php _e('%discount','usces'); ?> (<?php _e('Unit price','usces'); ?>) </td>
709 </tr>
710 <tr>
711 <td>3.<?php printf(__('in more than%s%s%s%s%s %s%s%s,', 'usces'), '<input type="text" name="', 'itemGpNum3', '" id="', 'itemGpNum3', '" class="itemPointrate"', 'value="', esc_attr($itemGpNum3), '" />'); ?><input type="text" name="itemGpDis3" id="itemGpDis3" class="itemPointrate" value="<?php echo esc_attr($itemGpDis3); ?>" /><?php _e('%discount','usces'); ?> (<?php _e('Unit price','usces'); ?>) </td>
712 </tr>
713 <?php apply_filters('usces_item_master_first_section', NULL, $post_ID); ?>
714 </table>
715 </div>
716
717 <div id="postitemcustomstuff">
718 <table class="iteminfo_table">
719 <?php
720 $second_section = '<tr>
721 <th>' . __('estimated shipping date', 'usces') . '</th>
722 <td><select name="itemShipping" id="itemShipping" class="itemShipping">';
723 foreach( (array)$this->shipping_rule as $key => $label){
724 $selected = $key == $itemShipping ? ' selected="selected"' : '';
725 $second_section .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_attr($label) . '</option>';
726 }
727 $second_section .= '</select>
728 <input type="hidden" name="itemShipping_nonce" id="itemShipping_nonce" value="' . wp_create_nonce( 'itemShipping_nonce' ) . '" /></td>
729 </tr>
730 <tr>
731 <th>' . __('shipping option','usces') . '</th>
732 <td>';
733 $delivery_methods = (array)$this->options['delivery_method'];
734 if( count($delivery_methods) === 0 ){
735 $second_section .= __('* Please register an item, after you finished delivery setting!','usces');
736 }else{
737 foreach( $delivery_methods as $deli){
738 $second_section .= '<label for="itemDeliveryMethod[' . $deli['id'] . ']"><input name="itemDeliveryMethod[' . $deli['id'] . ']" id="itemDeliveryMethod[' . $deli['id'] . ']" type="checkbox" value="' . esc_attr($deli['id']) . '"';
739 if(in_array($deli['id'], (array)$itemDeliveryMethod)) {
740 $second_section .= ' checked="checked"';
741 }
742 $second_section .= ' />' . esc_html($deli['name']) . '</label>';
743 }
744 }
745 $second_section .= '</td>
746 </tr>
747 <tr>
748 <th>' . __('Shipping', 'usces') . '</th>
749 <td><select name="itemShippingCharge" id="itemShippingCharge" class="itemShippingCharge">';
750 foreach( (array)$this->options['shipping_charge'] as $cahrge){
751 $selected = $cahrge['id'] == $itemShippingCharge ? ' selected="selected"' : '';
752 $second_section .= '<option value="' . $cahrge['id'] . '"' . $selected . '>' . esc_html($cahrge['name']) . '</option>';
753 }
754 $second_section .= '</select>
755 <input type="hidden" name="itemShippingCharge_nonce" id="itemShippingCharge_nonce" value="' . wp_create_nonce( 'itemShippingCharge_nonce' ) . '" /></td>
756 </tr>
757 <tr>
758 <th>' . __('Postage individual charging', 'usces') . '</th>
759 <td><input name="itemIndividualSCharge" id="itemIndividualSCharge" type="checkbox" value="1"';
760 if($itemIndividualSCharge){
761 $second_section .= ' checked="checked"';
762 }
763 $second_section .= ' /></td>
764 </tr>';
765 $second_section = apply_filters('usces_item_master_second_section', $second_section, $post_ID);
766 echo $second_section;
767 ?>
768 </table>
769 </div>
770
771 <!--<div class="meta-box-sortables">-->
772
773 <div id="itemsku" class="postbox">
774 <h3 class="hndle"><span>SKU <?php _e('Price', 'usces'); ?></span></h3>
775 <div class="inside">
776 <div id="postskucustomstuff"><div id="skuajax-response"></div>
777 <?php
778 $metadata = has_item_sku_meta($post->ID);
779 list_item_sku_meta($metadata);
780 item_sku_meta_form();
781 ?>
782 </div>
783 </div>
784 </div>
785
786 <div id="itemoption" class="postbox">
787 <h3 class="hndle"><span><?php _e('options for items', 'usces'); ?></span></h3>
788 <div class="inside">
789 <div id="postoptcustomstuff"><div id="ajax-response"></div>
790 <?php
791 $metadata = has_item_option_meta($post->ID);
792 list_item_option_meta($metadata);
793 item_option_meta_form();
794 ?>
795 </div>
796 </div>
797 </div>
798
799 <?php if ( defined('USCES_EX_PLUGIN') ){ ?>
800 <div id="itemoption" class="postbox">
801 <h3 class="hndle"><span><?php _e('Options for EX-plugin', 'usces'); ?></span></h3>
802 <div class="inside">
803 <div id="postoptcustomstuff">
804 <?php
805 apply_filters('usces_ex_plugin_options', &$usces_expo, $post->ID, 'A', 'B');
806 echo $usces_expo;
807 ?>
808 </div>
809 </div>
810 </div>
811 <?php } ?>
812 <!--</div>--><!--end of meta-box-sortables-->
813
814 <div id="titlediv">
815 <div id="titlewrap"><strong><?php _e('Title of detail page', 'usces'); ?></strong>
816 <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />
817 </div>
818 <div class="inside">
819 <?php $sample_permalink_html = get_sample_permalink_html($post->ID); ?>
820 <?php if ( !( 'pending' == $post->post_status && !current_user_can( 'publish_posts' ) ) ) { ?>
821 <div id="edit-slug-box">
822 <?php if ( ! empty($post->ID) && ! empty($sample_permalink_html) ) :
823 echo $sample_permalink_html;
824 endif; ?>
825 </div>
826 <?php } ?>
827 </div>
828 </div>
829
830 <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
831
832 <?php the_editor($post->post_content); ?>
833
834 <table id="post-status-info" cellspacing="0"><tbody><tr>
835 <td id="wp-word-count"></td>
836 <td class="autosave-info">
837 <span id="autosave">&nbsp;</span>
838 <?php
839 if ( $post_ID ) {
840 echo '<span id="last-edit">';
841 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
842 $last_user = get_userdata($last_id);
843 printf(__('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
844 } else {
845 printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
846 }
847 echo '</span>';
848 } ?>
849 </td>
850 </tr></tbody></table>
851
852 <?php wp_nonce_field( 'autosave', 'autosavenonce', false ); ?>
853 <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
854 <?php wp_nonce_field( 'getpermalink', 'getpermalinknonce', false ); ?>
855 <?php wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false ); ?>
856 <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
857 </div>
858
859 <!-- do_meta_boxes('post', 'normal', $post) -->
860 <?php do_meta_boxes('post', 'normal', $post); ?>
861 <!-- do_action('edit_form_advanced') -->
862 <?php do_action('edit_form_advanced'); ?>
863 <!-- do_meta_boxes('post', 'advanced', $post) -->
864 <?php do_meta_boxes('post', 'advanced', $post); ?>
865 <!-- do_action('dbx_post_sidebar') -->
866 <?php do_action('dbx_post_sidebar'); ?>
867
868
869 </div>
870 </div>
871 <br class="clear" />
872 </div><!-- /poststuff -->
873 <?php //wp_original_referer_field(true, 'current'); ?>
874 </form>
875 </div>
876 </div>
877 <!-- wp_comment_reply() -->
878 <?php wp_comment_reply(); ?>
879 <!-- END wp_comment_reply() -->
880 <?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?>
881 <script type="text/javascript">
882 try{document.post.itemCode.focus();}catch(e){}
883 try{
884 var dfo = document.post;
885 if(dfo.itemRestriction.value == '') dfo.itemRestriction.value = uscesL10n.purchase_limit;
886 if(dfo.itemPointrate.value == '') dfo.itemPointrate.value = uscesL10n.point_rate;
887 if(dfo.itemShipping.selectedIndex == '0') dfo.itemShipping.selectedIndex = uscesL10n.shipping_rule;
888 }catch(e){}
889
890 jQuery(document).ready(function($){
891 $("#in-category-"+<?php echo USCES_ITEM_CAT_PARENT_ID; ?>).attr({checked: "checked"});
892
893 $('#itemCode').blur(
894 function() {
895 if ( $("#itemCode").val().length == 0 ) return;
896 uscesItem.newdraft($('#itemCode').val());
897 });
898
899 });
900 </script>
901 <?php endif; ?>
902