Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes for WP 3.5

  • Loading branch information...
commit 5a4047b10c32a430398ce9b8c1f31643eadb083f 1 parent 2b10bde
@hunk authored
Showing with 40 additions and 38 deletions.
  1. +14 −6 Main.php
  2. +26 −32 js/custom_fields/datepicker.js
View
20 Main.php
@@ -311,12 +311,20 @@ function mf_load_modules() {
add_filter('attachment_fields_to_edit', 'charge_link_after_upload_image', 10, 2);
function charge_link_after_upload_image($fields){
- printf("
- <script type=\"text/javascript\">
- //<![CDATA[
- load_link_in_media_upload();
- //]]>
- </script>");
+ $wp_version = floatval(get_bloginfo('version'));
+
+ if(
+ $wp_version < 3.5 ||
+ (( isset($_REQUEST['fetch']) && $_REQUEST['fetch'] ) ||
+ ( isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'library' ))
+ ){
+ printf("
+ <script type=\"text/javascript\">
+ //<![CDATA[
+ load_link_in_media_upload();
+ //]]>
+ </script>");
+ }
return $fields;
}
View
58 js/custom_fields/datepicker.js
@@ -1,56 +1,46 @@
-jQuery(document).ready(function(){
-
- //Adding the datepicker event to the fields
- jQuery('.datebotton_mf').live('click',function(){
-
+jQuery(document).ready(function($){
+ jQuery('.datebotton_mf').live('click',function(){
the_id = jQuery(this).attr('id');
picker = the_id.replace(/pick_/,'');
format = jQuery('#format_date_field_'+picker).text();
format = switch_formats(format);
-
picker = 'display_date_field_' + picker;
-
- jQuery('#'+picker).datepicker({
- showAnim: 'fadeIn',
- changeYear: true,
- dateFormat: format,
- altFormat: "yy-mm-dd",
- altField: '#' + the_id.replace(/pick_/,'date_field_'),
+
+ jQuery('#'+picker).datepicker({
+ showAnim: 'fadeIn',
+ changeYear: true,
+ dateFormat: format,
+ altFormat: "yy-mm-dd",
+ altField: '#' + the_id.replace(/pick_/,'date_field_'),
showOn:'focus',
onClose: function(){
input = jQuery(this);
date = input.val();
- //id = input.attr('id').replace(/display_/,'');
- //jQuery('#'+id).val(date);
-
//unbind the event
jQuery(this).datepicker('destroy');
}
}).focus();
- });
-
- //TODAY Botton
+
+ });
+
+ //TODAY Botton
jQuery('.todaybotton_mf').live('click',function(){
the_id = jQuery(this).attr('id');
picker = the_id.replace(/today_/,'');
- today = 'tt_' + picker;
- today = jQuery('#'+today);
- today_raw = jQuery('#tt_raw_' + picker);
- date = today.val();
- date_raw = today_raw.val();
+ today = jQuery(this).attr('alt');
+ today_raw = jQuery(this).attr('rel');
- jQuery('#display_date_field_'+picker).val(date);
- jQuery('#date_field_'+picker).val(date_raw);
+ jQuery('#display_date_field_'+picker).val(today);
+ jQuery('#date_field_'+picker).val(today_raw);
});
-
- //BLANK Botton
+
+ //BLANK Botton
jQuery('.blankBotton_mf').live('click',function(){
the_id = jQuery(this).attr('id');
picker = the_id.replace(/blank_/,'');
- jQuery('#display_date_field_'+picker).val("");
- jQuery('#date_field_'+picker).val("");
+ jQuery('#display_date_field_'+picker).val("");
+ jQuery('#date_field_'+picker).val("");
});
-
});
//From php date format to jqueyr datepicker format
@@ -91,4 +81,8 @@ switch_formats = function(date){
if(date == "m.d.y"){
return "mm.dd.y";
}
-}
+
+ if(date == "d.m.Y"){
+ return "dd.mm.yy";
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.