Magenta Cuda
Forum Replies Created
-
Forum: Plugins
In reply to: [Magic Fields 2] populate checkbox_list with related type or termTry this:
<?php // This code should be in a file named "alt_related_type_field" in the folder "field_types" of Magic-Fields-2 // You also need to provide icon_color.png, icon_gray.png and preview.png which you can temporarily borrow // from its siblings for now. // initialisation global $mf_domain; // class with static properties encapsulating functions for the field type class alt_related_type_field extends mf_custom_fields { public $allow_multiple = TRUE; public $has_properties = TRUE; public function _update_description(){ global $mf_domain; $this->description = __("Checkbox list that lets a user select ONE or MORE related posts of a given post type.",$mf_domain); } public function _options(){ global $mf_domain; $posttypes = $this->mf_get_post_types(); $select = array(); foreach($posttypes as $k => $v){ $select[$k] = $v->label; } $data = array( 'option' => array( 'post_type' => array( 'type' => 'select', 'id' => 'post_type', 'label' => __('Related Type Panel (Post type)',$mf_domain), 'name' => 'mf_field[option][post_type]', 'default' => '', 'options' => $select, 'add_empty' => false, 'description' => '', 'value' => '', 'div_class' => '', 'class' => '' ), 'field_order' => array( 'type' => 'select', 'id' => 'field_order', 'label' => __('Field for order of Related type',$mf_domain), 'name' => 'mf_field[option][field_order]', 'default' => '', 'options' => array('id' => 'ID','title' =>'Title'), 'add_empty' => false, 'description' => '', 'value' => '', 'div_class' => '', 'class' => '' ), 'order' => array( 'type' => 'select', 'id' => 'order', 'label' => __('Order of Related type',$mf_domain), 'name' => 'mf_field[option][order]', 'default' => '', 'options' => array('asc' => 'ASC','desc' =>'DESC'), 'add_empty' => false, 'description' => '', 'value' => '', 'div_class' => '', 'class' => '' ) ) ); return $data; } public function display_field($field, $group_index = 1, $field_index = 1){ $output = ''; $check_post_id = null; if( !empty($_REQUEST['post'])) { $check_post_id = $_REQUEST['post']; } $values = array(); if($check_post_id){ $values = ($field['input_value']) ? (is_serialized($field['input_value']))? unserialize($field['input_value']): (array)$field['input_value'] : array() ; } $type = $field['options']['post_type']; $order = $field['options']['order']; $field_order = $field['options']['field_order']; $options = get_posts( sprintf("post_type=%s&numberposts=-1&order=%s&orderby=%s&suppress_filters=0",$type,$order,$field_order) ); $option_ids = []; foreach($options as $option) { $option_is[] = $option->ID; } $output = '<div class="mf-checkbox-list-box" >'; foreach($values as &$val){ $val = trim($val); } foreach($options as $option){ $check = in_array($option->ID, $values) ? 'checked="checked"' : ''; $output .= sprintf('<label for="%s_%s" class="selectit mf-checkbox-list">',$field['input_id'],$option->ID); $output .= sprintf('<input tabindex="3" class="checkbox_list_mf" id="%s_%s" name="%s[]" value="%s" type="checkbox" %s %s />', $field['input_id'],$option->ID,$field['input_name'],$option->ID,$check,$field['input_validate']); $output .= esc_attr($option->post_title); $output .= '</label>'; } $output .= '</div>'; #error_log( "##### alt_related_type_field::display_field() returns $output\n" ); return $output; } }
Forum: Plugins
In reply to: [Magic Fields 2] How to delete unused images?My previous SQL command will not work as wp_content/files_mf
folder contains file with no corresponding entry in the SQL database.However,
select meta_value from wp_postmeta
where meta_key in (select name from wp_mf_custom_fields
where type = ‘image’)
and post_id in (select ID from wp_posts
where post_status = ‘publish’ or post_status = ‘draft’
or post_status = ‘auto-draft’);should give you a list of currently in use images so the image files in wp_content/files_mf NOT in this list are the ones you want to delete.
Forum: Plugins
In reply to: [Magic Fields 2] How to delete unused images?Although I haven’t tried either Nicearma or Upload Janitor I strongly suspect that they will not work because Magic Fields use its own proprietary way of storing images for fields of type ‘image’. (Images of type ‘image_media’ are stored in the standard WordPress way.) In particular, Magic Field images are stored in the Magic Field’s specific folder ‘wp_content/files_mf’. Without code specific to Magic Fields a generic utility would not know about this Magic Field specific folder. It would be surprising if these generic utilities have Magic Field specific logic coded in it.
Forum: Plugins
In reply to: [Magic Fields 2] How to delete unused images?try this SQL command:
select meta_value from wp_postmeta
where meta_key in (select name from wp_mf_custom_fields
where type = ‘image’)
and post_id not in (select ID from wp_posts
where post_status = ‘publish’ or post_status = ‘draft’
or post_status = ‘auto-draft’);——————————————————————–
select name from wp_mf_custom_fields where type = ‘image’
gives field names of fields of type image
——————————————————————–
select ID from wp_posts where post_status = ‘publish’
or post_status = ‘draft’ or post_status = ‘auto-draft’
gives IDs of posts in publish or draft status
——————————————————————–
So we are selecting the value of fields of type image which do not
have a post that is currently published or in draft form.
These values are the file names of files in the wp_content/files_mf
folder. Alternatively you can try using post_status = ‘trash’I just checked out the latest github version and “Media Library” tab is now working. The line added to function mf_use_new_image_gallery()
if (typeof wp === ‘undefined’ || typeof wp.media === ‘undefined’) return;
I think fixed the problem.
I also noticed that the “Media Library” tab is working in the WordPress version but broken in the GitHub version. The problem seems to be that the WordPress version displays the “…/wp-admin/media-upload.php?…” page in an iframe hosted by an overlaid div whereas the GitHub version loads a new page and consequently the global window.mf_field_id is undefined.
I have done more investigating of this problem.
In the call in file
“… \wp-content\plugins\types\embedded\includes\fields-post.php”
on line 905$post_type = get_post_type($post);
$post is not a real post object but a dummy created in
“… \wp-content\plugins\types\embedded\includes\post-relationship.php”
on lines 284-288 as follows:
$item->ID = ‘new_’ . wpcf_unique_id(serialize($post));
$item->post_title = ”;
$item->post_content = ”;
$item->post_type = $post_type;I am not sure what get_post_type($post) should do when it is called on a non-existent dummy post object but it seems like a bad idea and anyway in this case the call is unnecessary since post_type is a field in the dummy object.
So I think line 905 of file
“… \wp-content\plugins\types\embedded\includes\fields-post.php”
should be changed from
$post_type = get_post_type($post);
to:
$post_type = $post->post_type;Hi tanc,
I just re-verified the work around again on my system so there must be some crucial difference in our two systems.
First let us make sure we changed the same things:
In file “… \wp-content\plugins\types\embedded\includes\fields-post.php” line 905 was changed from:
$post_type = get_post_type($post);
to:
$post_type = get_post_type($post->ID);After this change are you getting exactly the same error “Post not updated. Relationship data missing.” or a new one.
My WordPress version is 3.5 and Types version is 1.1.3.3.
Are you running any other plugins? I run only one other plugin BackWPup. (I don’t actually use Types for real work but I have it around for evaluation purposes only – hence the stripped environment.)This error is very strange. The developers states 1.1.3.3 is verified on WP 3.5.0 so this must be working on the developers’ system. But it is just completely broken on my system. The above two calls to get_post_type() should be equivalent but on my system at least they are not.
Anyway I find this problem interesting and would greatly appreciate getting more info from you.
Forum: Plugins
In reply to: [Magic Fields 2] how to get a field option from wp_mf_custom_fields table?This call
get_field_options( ‘your related field’, get_post_type() )[‘post_type’]
using code from here should do it.
Really good news. The developers have changed their mind and have released WordPress 3.5 compatible versions 2.1 and 1.6. I have now tested 5 non-premium CMS plugins – Magic Fields, Advanced Custom Fields (non-premium features only), Types (non-premium features only), Pods and More Fields (with More Types and More Taxonomies) and for what I want to Magic Fields is still the best.
Thanks for the advice. I have switched to version 2 but recently learned that the developer of Magic Fields has announced that he will stop supporting it. I am now trying “Advanced Custom Fields” but for what I want to do it isn’t as good as Magic Fields. I hope someone new takes over Magic Fields. May try “Meta Box” later.
On the very same day that I wrote this review the developer announced that he will stop supporting Magic Fields. The only upside for me is that I have invested only about ten days time into Magic Fields. Really regrettable as this was quite a nice plugin. My search for a good CMS plugin goes on ….
I think the design and implementation of Pods for the most part is excellent. It is both easy to understand and easy to use. However, I find the design and implementation of custom taxonomies for an advanced content type pod neither easy to understand nor easy to use. Even worse the UI to the end user (content provider not viewer) is not user friendly. It may be that I am doing something wrong but it took me more than a day to get to this solution. (A major problem is advanced content type is poorly documented.) Using a different CMS plugin I was able to do this in minutes. Let me be more specific about what I am trying to do. I want to specify the available factory colors of a car. This can be implemented either as a multi-valued string field or alternatively as a custom taxonomy. After more than a day of work the only solution I came up with wasn’t ideal. (I never found example code on how to do this and my solution may be wrong.) My personal feeling is that this part of Pods needs to be re-designed. It doesn’t match the standard of excellence the rest of Pods has achieved.
Forum: Plugins
In reply to: [Magic Fields] [Plugin: Magic Fields] Compatibility with WP 3.4I am using 3.4.2 and Magic Fields seems to be working.
I have finally found away to make this work using as you suggested relationship fields. However, I am forced to use a custom WP_Query() instead of pods(). Is there another way?