WordPress.org

Support

Support » Plugins and Hacks » Media Custom Fields » [Plugin: Media Custom Fields] no custom fields breaks foreach loop.

[Plugin: Media Custom Fields] no custom fields breaks foreach loop.

  • Minor fix, if you havent made any custom fields yet, the foreeach in line 233 will complain.

    media-custom-fields.php

    Inserting an “if ($tqmcf)” (check that the variable isent empty):

    function tqmcf_edit( $form_fields, $post ) {
    		$tqmcf = get_tqmcf();
    
            if ($tqmcf) // new
            { // new
    		  foreach ( $tqmcf as $field )
              {
    			$form_fields[$field["slug"]]['label'] = $field['name'];
    			$form_fields[$field["slug"]]['value'] = get_post_meta( $post->ID, $field["slug"], true );
    			$form_fields[$field["slug"]]['helps'] = $field['description'];
    		  }
            }  // new
              return $form_fields;
        }

    very usefull plugin :thumbs-up:

    http://wordpress.org/extend/plugins/media-custom-fields/

Viewing 1 replies (of 1 total)
  • Also the same loop issue when in the admin line 101

    admin/administration_page.php

    if ($tqmcf)  // not empty  // new
                { // new
      			  $fields = array();
                  foreach($tqmcf as $field) {
    				$fields[] = $field["slug"];
    			  }
    
    			$fields = "'".implode("', '", $fields)."'";
    			$items = $wpdb->get_col("SELECT DISTINCT(meta_key) FROM $wpdb->postmeta WHERE meta_key LIKE '%tqmcf_%' AND
    				meta_key NOT IN ($fields)
    			");
                }  // new

    again, this is a nice plugin 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Media Custom Fields] no custom fields breaks foreach loop.’ is closed to new replies.
Skip to toolbar