Forum Replies Created
-
AuthorPosts
-
thorMemberIt is not a RoyalSlider issue – but Piklist when a field is called ‘id’.
(I need it to specifically be “id” so RoyalSlider picks up the attribute, so the solution is not using e.g. “my_id”)If I add the following then [blabla] is printed out but [blabla id=”first”] is expected :
<?php /* Name: Blabla Description: Testing Shortcode: blabla Icon: dashicons-format-gallery */ piklist('field', array( 'type' => 'select', 'field' => 'id', 'label' => 'My select', 'choices' => array( 'first' => 'First Choice', 'second' => 'Second Choice', 'third' => 'Third Choice' ) ));
thorMemberany suggestions on solving this?
thorMemberHi Steven
I know how to create a hidden field – I just don’t know how to have one value from a piklist field saved into another (the hidden).
Field A (text) holds ‘This is my title| with a special character’
Field B (hidden) should save Field A in a HTML format ‘This is my title<br/> with a special character’
thorMember(but the space prefix hack with id is preventing the edit from working – since the space messes op the HTML class/ID so it won’t be able to fetch the value from the shortcode)
thorMemberI have tried, but then it removes all shortcodes and displays [piklist_form form="shortcode"] (as text) in the window
add_action( 'init', 'remove_piklist_shortcodes',1000 ); function remove_piklist_shortcodes() { remove_shortcode( 'piklist_form' ); }Just to clarify, I want to use my own piklist shortcodes – but I have no use for the piklist_form. Any suggestions?
thorMemberRight know I have this meta-box field
/* Title: Intro Post Type: projects */ piklist('field', array( 'type' => 'text', 'field' => 'project_introtitle', 'label' => 'Project title', 'columns' => 4, 'sanitize' => array( array( 'type' => 'title_sanitization', // defined in functions.php (piklist-functions.php) 'options' => 'html' // used as custom field suffix ) ), 'attributes' => array( 'placeholder' => get_the_title() ) ));In functions.php I have this sanitization and a bit of a hack for saving the field in a html version:
// Piklist sanitize titles (Allow forced breaks) and soft hyphens add_filter('piklist_sanitization_rules', 'sanitize_title_function', 11); function sanitize_title_function($sanitization_rules) { $sanitization_rules['title_sanitization'] = array( 'callback' => 'sanitize_title_callback' ); return $sanitization_rules; } function sanitize_title_callback($value, $field, $options) { $returntitle = trim(preg_replace('/\s+/', ' ', $value)); // removes any extra (unwanted) spaces $postid = intval( $field["object_id"] ); $this_field = $field["field"]; if (isset($options) && '' !== $options && !is_array($options)) { $suffix = '_' .sanitize_html_class($options); $htmltitle = str_replace('|', '<br />', $returntitle); $htmltitle = str_replace('_', '­', $htmltitle); update_post_meta( $postid, $this_field . $suffix, $htmltitle ); // extra meta (using suffix) } return $returntitle; }So this is a bit hacky, and it will not work serialized arrays. So what would be the proper solution – saving to a hidden piklist field that works with groups and repeaters?
thorMemberI had a problem once with custom fields not being saved on pages – don’t know if it relates to this problem, but it worked for me. The workaround was to remove WP’s custom-fields:
add_action( 'init', 'custom_fields_work' ); function custom_fields_work() { remove_post_type_support( 'page', 'custom-fields' ); }
thorMemberThanks Steve, I know how to create the hidden field. But how can it use the non-hidden text field? So I have the hidden field with the HTML version of the custom_title?
I can run a manual ‘update_post_meta’ in my sanitize callback where I store the HTML version in a meta field. But this is not ideal for serialized arrays (when I have used Group fields)
thorMemberah yes, I think that makes sense 🙂
thorMemberThanks @Steve.
But I am not sure if it will work in my case.
Imagine a site with authors, that each have their public “author profile page” – where they have som featured posts.
I want to use piklist to have a checkbox saying “feature this post” (which will determine if the post is shown on their author page). So this box is per user, hence I was wondering if ‘field’ => ‘my_featured_post_’+$user_id would be the best approach? Each user would only see their own “feature this post” field.
thorMember@Steve – Thanks. Now it works 🙂
thorMemberI have added it to the functions.php but somehow this isn’t working?
December 17, 2017 at 9:19 am in reply to: Possible to add meta-box in Media Library (post type "attachment")? #8598
thorMemberany news on this feature?
thorMembercommenting out add_filter(‘tiny_mce_before_init’, array(‘piklist_form’, ‘remove_theme_css’), 10, 2); on line 263 in /wp-content/plugins/piklist/includes/class-piklist-form.php makes it work. but is there a proper solution?
thorMember -
AuthorPosts