init(); // do_action(''); $type = attribute_escape($_GET['type']); $pages = $mf0->get_pages(); $option = $mf0->get_option('options'); // If the page type does not exist, then stop! // if (!array_key_exists($type, $pages)) exit(); if ($_GET['action'] == 'get_file_list') { $post_id = attribute_escape($_GET['post_id']); $attachments['data'] = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') ); $attachments['clicked'] = attribute_escape($_GET['clicked']); echo json_encode($attachments); exit(); } ?> jQuery(document).ready(function(){ if (jQuery("#titlediv")) { var html = '

'; html = html + '

'; jQuery("#post_status").after(html); if (typeof(postboxes) != 'undefined') postboxes.add_postbox_toggles(''); // Show the file list box jQuery('.mf_file_list_show').each(function(one){ if (!jQuery('#' + this.id.replace('mf_file_list_show_', '')).val()) { jQuery('#' + this.id).hide(); jQuery('#' + this.id.replace('show', 'edit')).show(); } else { jQuery('#' + this.id).show(); jQuery('#' + this.id.replace('show', 'edit')).hide(); } }); // Bind the file list field type jQuery('.file_list_update').bind('click', function(){ var regexp = /edit/; if (regexp.test(this.id)) { jQuery('#' + this.id.replace('edit_button', 'edit')).show(); jQuery('#' + this.id.replace('edit_button', 'show')).hide(); var clicked = this.id.replace('mf_file_list_edit_button_', ''); } else { var clicked = this.id.replace('mf_file_list_update_button_', ''); } var url = '/wp-content/plugins/more-fields/more-fields-write-js.php?'; url = url + 'post_id=' + jQuery('#post_ID').val() + '&action=get_file_list&clicked=' + clicked; jQuery.getJSON(url, function(json){ html = ''; jQuery.each(json['data'], function(i, file){ html = html + ''; }); jQuery('#' + json['clicked'] + '_temp').html(html); }); }); // Bind the file list select list to set the real id jQuery('.mf_file_list_select').bind('select', function(){ if (this.value) jQuery('#' + this.id.replace('_temp', '')).val(this.value); }); // Hide some boxes all_boxes($pages[$type]['based_on']); foreach ($allboxes as $box_id) { if (!isset($pages[$type]['visible_boxes'])) continue; if (!in_array($box_id, (array) $pages[$type]['visible_boxes'])) { ?> jQuery('#').hide(); jQuery("label[for='-hide']").hide(); // Make sure correct sub-menu is current jQuery(".wp-has-current-submenu").removeClass('wp-has-current-submenu').removeClass('wp-menu-open'); jQuery(".current").removeClass('current'); jQuery("#menu-").addClass("wp-has-current-submenu").addClass("wp-menu-open"); // Check the right sub-sub-menu jQuery("#menu- > .wp-has-submenu").addClass("wp-has-current-submenu").addClass("wp-menu-open"); if (jQuery("h2").filter(":contains('')").html()) { jQuery("#menu- .wp-first-item").addClass("current"); } else if (jQuery("h2").filter(":contains('')").html()) { jQuery("#menu- .wp-first-item").next("li > a").addClass("current"); jQuery(".current > a").addClass("current"); } jQuery("h2").filter(":contains('')").html(''); jQuery("h2").filter(":contains('')").html(''); // Fix the menu //jQuery("#submenu a.current").removeClass("current"); //jQuery('#submenu a').filter(":contains('')").addClass("current"); // These are the category ids for this post type // Uncheck all the cats (strict enforcement) jQuery("input[name*='post_category']").each(function(i){ var id = this.id.replace('in-category'); jQuery('#in-category-' + id).attr({checked: ''}); jQuery('#in-popular-category-' + id).attr({checked: ''}); }); jQuery("#in-category-").attr({checked: 'checked'}); jQuery("#in-popular-category-").attr({checked: 'checked'}); // Add tags if there are none. var tags = jQuery("#tags-input").val(); if (tags) { if (!tags.length) { if (jQuery("#newtag")) { jQuery("#newtag").val(""); tag_flush_to_text(); } else { jQuery("#tags-input").val(", " + tags); } } } } });