From c898410981abc5a1c030bfbf917de279cebd9bdb Mon Sep 17 00:00:00 2001 From: Tom Ransom Date: Mon, 26 Aug 2013 11:08:30 -0700 Subject: [PATCH 1/3] removes not found error in admin - Javascript != PHP - re-did functions in form of func_name = function() --- js/mf_admin.js | 54 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/js/mf_admin.js b/js/mf_admin.js index ebe3dc1..acdb03b 100644 --- a/js/mf_admin.js +++ b/js/mf_admin.js @@ -1,5 +1,5 @@ jQuery(document).ready(function($) { - //Custom Validataion methods + //Custom Validataion methods jQuery.validator.addMethod( "lowercase", function(value, element) { return this.optional(element) || /^[0-9a-z\_]+$/.test(value); },'Only are accepted lowercase characters,numbers or underscores'); @@ -14,7 +14,7 @@ jQuery(document).ready(function($) { name = $('#posttype-type').val(); id = $('#posttype-id').val(); var status = 0; - + jQuery.ajax({ url: ajaxurl, type: 'POST', @@ -38,7 +38,7 @@ jQuery(document).ready(function($) { return false; }); - + //validation custom group $('#addCustomGroup').submit(function(){ name = $("#custom_group_name").val(); @@ -68,9 +68,9 @@ jQuery(document).ready(function($) { return true; return false; - + }); - + //validation custom field $('#addCustomField').submit(function(){ name = $("#customfield-name").val(); @@ -98,10 +98,10 @@ jQuery(document).ready(function($) { } if(status) return true; - - return false; + + return false; }); - + //validation custom taxonomy $('#addCustomTaxonomy').submit(function(){ type = $("#custom-taxonomy-type").val(); @@ -128,13 +128,13 @@ jQuery(document).ready(function($) { } if(status) return true; - - return false; + + return false; }); - - //Confirm for display a confirm box + + //Confirm for display a confirm box $('.mf_confirm').click(function() { - message = $(this).attr('alt'); + message = $(this).attr('alt'); return confirm_message(message); }); @@ -172,11 +172,11 @@ jQuery(document).ready(function($) { }); -function suggestCustomFieldName(){ +suggestCustomFieldName = function(){ if (jQuery('#customfield-label').length > 0 && jQuery('#customfield-name').length > 0 && jQuery("#customfield-name").val() == '') { jQuery('#customfield-label').stringToSlug({ space:'_', - getPut:'#customfield-name', + getPut:'#customfield-name', prefix:jQuery('#name_group_slug').val() + " ", replace:/\s?\([^\)]*\)/gi }); @@ -192,8 +192,8 @@ confirm_message = function(message) { } } -function load_link_in_media_upload(){ - +load_link_in_media_upload = function(){ + jQuery('a.del-link').each(function(){ id = jQuery(this).next().attr('id'); check_repet = jQuery(this).prev().attr('class'); @@ -203,13 +203,13 @@ function load_link_in_media_upload(){ if(check == "" || check == undefined ){}else{ set = parent.window.mf_js.mf_image_media_set; jQuery(this).before(''+set+''); - jQuery(this).parent().find("input:submit").remove(); + jQuery(this).parent().find("input:submit").remove(); } } }); } -function mf_set_image_field(id){ +mf_set_image_field = function(id){ id_element = parent.window.mf_field_id; jQuery.post(parent.window.mf_js.mf_url+"admin/MF_ImageMedia.php", { "image_id": id, 'field_id': id_element }, function(data){ @@ -230,18 +230,18 @@ jQuery(document).ready(function($){ if (check){ set = parent.window.mf_js.mf_image_media_set; $(this).before(''+set+''); - $(this).parent().find("input:submit").remove(); + $(this).parent().find("input:submit").remove(); } }); $(document).on('click', '.update_field_media_upload',function(){ window.mf_field_id = jQuery(this).attr('id'); }); - + $('#set-post-thumbnail , #add_image').click( function(){ window.mf_field_id = ''; }); - + $(document).on('click',".mce_add_image , .mce_add_video , .mce_add_audio , .mce_add_media",function(){ window.mf_field_id = ''; var a = this; @@ -250,14 +250,14 @@ jQuery(document).ready(function($){ tinyMCE.activeEditor = tinyMCE.EditorManager.getInstanceById( a.id.replace('_add_media', '') ); wpActiveEditor = a.id.replace('_add_media', ''); }, 500 ); - + }); }); -function mf_use_new_image_gallery(){ - - if (typeof wp === 'undefined' || typeof wp.media === 'undefined') return; - +mf_use_new_image_gallery = function(){ + + if (typeof wp === 'undefined' || typeof wp.media === 'undefined') return; + var _custom_media = true; _orig_send_attachment = wp.media.editor.send.attachment; From a7a49f30172014c96631cc97cfe6ed1676b8b4dd Mon Sep 17 00:00:00 2001 From: Tom Ransom Date: Mon, 26 Aug 2013 11:16:06 -0700 Subject: [PATCH 2/3] Revert "removes not found error in admin - Javascript != PHP - re-did functions in form of func_name = function()" This reverts commit c898410981abc5a1c030bfbf917de279cebd9bdb. --- js/mf_admin.js | 54 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/js/mf_admin.js b/js/mf_admin.js index acdb03b..ebe3dc1 100644 --- a/js/mf_admin.js +++ b/js/mf_admin.js @@ -1,5 +1,5 @@ jQuery(document).ready(function($) { - //Custom Validataion methods + //Custom Validataion methods jQuery.validator.addMethod( "lowercase", function(value, element) { return this.optional(element) || /^[0-9a-z\_]+$/.test(value); },'Only are accepted lowercase characters,numbers or underscores'); @@ -14,7 +14,7 @@ jQuery(document).ready(function($) { name = $('#posttype-type').val(); id = $('#posttype-id').val(); var status = 0; - + jQuery.ajax({ url: ajaxurl, type: 'POST', @@ -38,7 +38,7 @@ jQuery(document).ready(function($) { return false; }); - + //validation custom group $('#addCustomGroup').submit(function(){ name = $("#custom_group_name").val(); @@ -68,9 +68,9 @@ jQuery(document).ready(function($) { return true; return false; - + }); - + //validation custom field $('#addCustomField').submit(function(){ name = $("#customfield-name").val(); @@ -98,10 +98,10 @@ jQuery(document).ready(function($) { } if(status) return true; - - return false; + + return false; }); - + //validation custom taxonomy $('#addCustomTaxonomy').submit(function(){ type = $("#custom-taxonomy-type").val(); @@ -128,13 +128,13 @@ jQuery(document).ready(function($) { } if(status) return true; - - return false; + + return false; }); - - //Confirm for display a confirm box + + //Confirm for display a confirm box $('.mf_confirm').click(function() { - message = $(this).attr('alt'); + message = $(this).attr('alt'); return confirm_message(message); }); @@ -172,11 +172,11 @@ jQuery(document).ready(function($) { }); -suggestCustomFieldName = function(){ +function suggestCustomFieldName(){ if (jQuery('#customfield-label').length > 0 && jQuery('#customfield-name').length > 0 && jQuery("#customfield-name").val() == '') { jQuery('#customfield-label').stringToSlug({ space:'_', - getPut:'#customfield-name', + getPut:'#customfield-name', prefix:jQuery('#name_group_slug').val() + " ", replace:/\s?\([^\)]*\)/gi }); @@ -192,8 +192,8 @@ confirm_message = function(message) { } } -load_link_in_media_upload = function(){ - +function load_link_in_media_upload(){ + jQuery('a.del-link').each(function(){ id = jQuery(this).next().attr('id'); check_repet = jQuery(this).prev().attr('class'); @@ -203,13 +203,13 @@ load_link_in_media_upload = function(){ if(check == "" || check == undefined ){}else{ set = parent.window.mf_js.mf_image_media_set; jQuery(this).before(''+set+''); - jQuery(this).parent().find("input:submit").remove(); + jQuery(this).parent().find("input:submit").remove(); } } }); } -mf_set_image_field = function(id){ +function mf_set_image_field(id){ id_element = parent.window.mf_field_id; jQuery.post(parent.window.mf_js.mf_url+"admin/MF_ImageMedia.php", { "image_id": id, 'field_id': id_element }, function(data){ @@ -230,18 +230,18 @@ jQuery(document).ready(function($){ if (check){ set = parent.window.mf_js.mf_image_media_set; $(this).before(''+set+''); - $(this).parent().find("input:submit").remove(); + $(this).parent().find("input:submit").remove(); } }); $(document).on('click', '.update_field_media_upload',function(){ window.mf_field_id = jQuery(this).attr('id'); }); - + $('#set-post-thumbnail , #add_image').click( function(){ window.mf_field_id = ''; }); - + $(document).on('click',".mce_add_image , .mce_add_video , .mce_add_audio , .mce_add_media",function(){ window.mf_field_id = ''; var a = this; @@ -250,14 +250,14 @@ jQuery(document).ready(function($){ tinyMCE.activeEditor = tinyMCE.EditorManager.getInstanceById( a.id.replace('_add_media', '') ); wpActiveEditor = a.id.replace('_add_media', ''); }, 500 ); - + }); }); -mf_use_new_image_gallery = function(){ - - if (typeof wp === 'undefined' || typeof wp.media === 'undefined') return; - +function mf_use_new_image_gallery(){ + + if (typeof wp === 'undefined' || typeof wp.media === 'undefined') return; + var _custom_media = true; _orig_send_attachment = wp.media.editor.send.attachment; From fdeb2a86f77f70f00f0a4b94aac5b36c0c6be6fa Mon Sep 17 00:00:00 2001 From: Tom Ransom Date: Mon, 3 Mar 2014 11:06:58 -0800 Subject: [PATCH 3/3] Check for presence of 'quantity' in post-type before using in conditional --- mf_register.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mf_register.php b/mf_register.php index 2894f8a..f9aaba2 100644 --- a/mf_register.php +++ b/mf_register.php @@ -5,11 +5,11 @@ class mf_register{ public $name = 'mf_register'; - + function __construct(){ add_action('init', array( &$this, 'mf_register_custom_taxonomies' ) ); add_action('init', array( &$this, 'mf_register_post_types' ) ); - + } // register post type @@ -17,7 +17,7 @@ public function mf_register_post_types(){ global $mf_pt_register,$mf_pt_unique; $post_types = $this->_get_post_types(); - + foreach($post_types as $p){ $p = unserialize($p['arguments']); @@ -43,10 +43,10 @@ public function mf_register_post_types(){ $option['taxonomies'][] = $k; } } - if(isset($option['has_archive']) && $option['has_archive'] && isset($option['has_archive_slug']) && $option['has_archive_slug']) + if(isset($option['has_archive']) && $option['has_archive'] && isset($option['has_archive_slug']) && $option['has_archive_slug']) $option['has_archive'] = $option['has_archive_slug']; - - + + if($option['rewrite'] && $option['rewrite_slug']) $option['rewrite'] = array( 'slug' => $option['rewrite_slug'],'with_front' => $option['with_front']); @@ -65,19 +65,19 @@ public function mf_register_post_types(){ }elseif( !in_array($option['capability_type'],array('post','page')) ){ $option['capabilities'] = $this->_get_cap($option['capability_type']); } - + //description $option['description'] = $p['core']['description']; register_post_type($name,$option); //add unique post type - if ($p['core']['quantity']) { + if ( isset($p['core']['quantity']) && $p['core']['quantity'] ) { array_push($mf_pt_unique, "edit.php?post_type=".$name); } - - + + } - + } public function _get_cap($name){ @@ -122,8 +122,8 @@ public function mf_register_custom_taxonomies(){ } - /** - * return all post types + /** + * return all post types */ private function _get_post_types(){ global $wpdb; @@ -133,8 +133,8 @@ private function _get_post_types(){ return $posttypes; } - /** - * return all custom_taxonomy + /** + * return all custom_taxonomy */ private function _get_custom_taxonomies(){ global $wpdb;