Forum Replies Created

Viewing 15 posts - 31 through 45 (of 46 total)
  • Author
    Posts
  • in reply to: Shortcode problems #9491
    thor
    Member

    It 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'
    	)
    ));
    in reply to: Shortcode problems #9475
    thor
    Member

    any suggestions on solving this?

    in reply to: Save to hidden #9417
    thor
    Member

    Hi 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’

    in reply to: Shortcode problems #9413
    thor
    Member

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

    in reply to: Disable piklist_form from shortcodes #9411
    thor
    Member

    I 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?

    in reply to: Save to hidden #9406
    thor
    Member

    Right 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('_', '&shy;', $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?

    in reply to: Piklist 1.0.3 + WP 5.0.3 – Metaboxes not saving #9401
    thor
    Member

    I 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' );
    }
    in reply to: Save to hidden #9400
    thor
    Member

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

    in reply to: field reflecting current user #8898
    thor
    Member

    ah yes, I think that makes sense 🙂

    in reply to: field reflecting current user #8896
    thor
    Member

    Thanks @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.

    in reply to: remove piklist_love #8855
    thor
    Member

    @Steve – Thanks. Now it works 🙂

    in reply to: remove piklist_love #8850
    thor
    Member

    I have added it to the functions.php but somehow this isn’t working?

    thor
    Member

    any news on this feature?

    in reply to: bug – theme styling removed on editor? #7450
    thor
    Member

    commenting 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?

    in reply to: meta-box for selecting navigation menu? #6733
    thor
    Member
Viewing 15 posts - 31 through 45 (of 46 total)