Tuesday 15 April 2014

wordpress - Customising meta_form() in wp-admin/includes/template.php -


Hi all I'm a wordpress job so please bear with me. So in template.php, I need the functionality of the meta_form () function to change based on certain conditions, here it is visible:

Original code:

  function meta_form () {global $ wpdb; $ Limit = (int) apply_filters ('postmeta_form_limit', 30); $ Keys = $ wpdb- & gt; Get_col ("meta_key is not meta_key on meta_key from $ wpdb- & gt; meta_key from meta_key; does not like meta_key '' limit limit to limit of% _ meta_") ;; If ($ keys) natcasesort ($ key); ? & Gt;   

Customized version:

  function meta_form () {global $ wpdb; If (isset ($ _GET ['post'])) $ post_id = (int) $ _GET ['post']; Otherwise (isset ($ _ POST ['post_ID'])) $ post_id = (int) $ _POST ['post_ID']; Else $ post_id = 0; If ($ post_id) {$ post_ = get_post ($ post_id); } If ($ post_-> post_type == 'video_foto') {$ limit = (int) apply_filters ('postmeta_form_limit', 30); $ Keys = $ wpdb- & gt; Get_col (SELECT meta_key $ wpdb-> PostMeta from meta_key, where meta_key like meta_quitting meta_ is not 'meta_' like 'meta_key' is not like 'limit limit $');} and {$ border = (integer ) Apply_filters ('postmeta_form_limit', 30); $ Keys = $ wpdb- & gt; get_col ("$ wpdb-> from meta_key from meta_key meta_key on meta_key is not meta_key is not liked ''% _ limit to meta_match Limit ");;} What is the best way to overwrite the ($ keys) natcasesort ($ keys);? & Gt;   

meta_form function ? What am I Have to make a plugin or something? I can not seem to find a clean answer (PS I did not write this code, I'm just fixing it).

MetaForm functions is not plugged in, and no hook is available, therefore, hacking of the core is not really recommended; The following is a jQuery solution that will require the code to code functions.php of your theme Put in the file, or in a plug-in:

  add_action ('admin_footer', 'so17239871_mod_metakeyselect'); Function SO17239871_mod_metakeyselect () {global $ pagenow, $ post_type; If (! ('Post.php' == $ pages and video_photo == $ post_type)) return; ? & Gt; & Lt; Script type = "text / javascript" & gt; JQuery (document) .ready (function () {jQuery ("#metakeyselect" option). Hide (); jQuery ("#metakeyselect> option [value ^ = 'tqmcf _']"). Show ();} ); & Lt; / Script & gt; & Lt ;? Php}    

No comments:

Post a Comment