WordPress.org

Ready to get started?Download WordPress

Forums

Media Custom Fields
no custom fields breaks foreach loop. (2 posts)

  1. maxemil
    Member
    Posted 2 years ago #

    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/

  2. maxemil
    Member
    Posted 2 years ago #

    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 :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic