Forum Replies Created

Viewing 15 posts - 106 through 120 (of 125 total)
  • Author
    Posts
  • in reply to: how to use editor_css? #4660
    mcmaster
    Member

    Okay, so I defined a CSS class and put it into a file in the parts/css folder:

    .mcw-editor-short {
    	height: 140px;
    }

    And then I added editor_class to an editor field:

    		array(
    			'type' => 'editor',
    			'field' => 'newsletter_highlights',
    			'label' => __( 'Highlights of this issue' ),
    			'columns' => 12,
    			'options' => array (
    				'media_buttons' => false,
    				'editor_class' => 'mcw-editor-short',
    				'teeny' => true,
    			),
    		),
    

    But the class is applied to a textarea that is display: none, so it doesn’t affect the height of the editor box. See attached Firebug screenshot.

    Again, could be pilot error … so set me straight if I’m goofing up! 🙂

    Donna

    Attachments:
    You must be logged in to view attached files.
    in reply to: how to use editor_css? #4659
    mcmaster
    Member

    And I know I can use editor_class. Just wondering if there is a method that doesn’t require setting up a CSS file. Lazy. 😉

    in reply to: how to use editor_css? #4658
    mcmaster
    Member

    Also, is there a better way to limit the height of an editor field? I tried

    	'attributes' => array (
    		'rows' => 3,
    	),
    

    But that doesn’t work.

    Thanks!
    Donna

    in reply to: file upload labels misplaced in add-more (0.9.9.4) #4655
    mcmaster
    Member

    @Steve, thanks for the reminder about columns. I must confess I’ve never taken the time to figure out how they work. :-/ Will do that today!

    in reply to: file upload labels misplaced in add-more (0.9.9.4) #4645
    mcmaster
    Member

    Since it won’t allow me to upload the .php file, here’s the field definition:

    piklist('field', array(
    	'type' => 'group',
    	'field' => 'newsletter_archive',
    	'label' => 'Newsletter Archives',
    	'description' => 'Each archive includes an image, title and section for highlighting the content of the newsletter.',
    	'columns' => 12,
    	'add_more' => true,
    	'template' => 'field',
    	'fields' => array(
    		array(
    			'type' => 'text',
    			'field' => 'newsletter_archive_title',
    			'label' => 'Issue Date',
    		),
    		array(
    			'type' => 'file',
    			'field' => 'newsletter_file',
    			'label' => 'Upload or choose a PDF',
    			'options' => array(
    				'modal_title' => 'Add File(s)',
    				'button' => 'Add',
    			),
    		),
    		array(
    			'type' => 'editor',
    			'field' => 'newsletter_highlights',
    			'label' => __( 'Highlights of this issue' ),
    			'options' => array (
    				'wpautop' => true,
    				'media_buttons' => false,
    				'tabindex' => '',
    				'editor_css' => '',
    				'editor_class' => '',
    				'teeny' => false,
    				'dfw' => false,
    				'tinymce' => true,
    				'quicktags' => true,
    			),
    		),
    		array(
    			'type' => 'file',
    			'field' => 'newsletter_image',
    			'label' => 'Add a cover image',
    			'options' => array(
    				'modal_title' => 'Add File(s)',
    				'button' => 'Add',
    			),
    		),
    	),
    ));
    in reply to: 0.9.9.1 doesn't offer to run update script #4490
    mcmaster
    Member

    Thanks, Steve! Heading for California first thing in the morning so I’ll have to let someone else test this one. 😉 By the time I’m back on the web Saturday morning you’ll probably have another release!

    in reply to: 0.9.9.1 doesn't offer to run update script #4480
    mcmaster
    Member

    One tip for anyone who has defined piklist fields inside their theme.

    In order to deactivate Piklist, I renamed my theme’s piklist file to piklistx. Then I switched to the new Piklist plugin files, reactivated it, and ran the update. Oops, it didn’t find my theme’s piklist parts so it didn’t run the update on them.

    So if you use this method to deactivate Piklist before the upgrade, make sure you switch the name back before running the database update.

    #creativewaystomessup

    in reply to: 0.9.9.1 doesn't offer to run update script #4479
    mcmaster
    Member

    On a hunch, I decided to try it with 0.9.9, and it works. So maybe the functionality got lost in 0.9.9.1?

    in reply to: Hide metabox/field if post has parent #4472
    mcmaster
    Member

    @erikkubica, oh yes, I am also quite good at making my solutions more complex than the problems 🙂

    in reply to: Hide metabox/field if post has parent #4469
    mcmaster
    Member

    Thanks, @Steve. But I just realized I got it backwards. I think @erikkubica wants:

    if ( !$post->post_parent ) {
        // define fields here
    }

    It’s those details that always bite me! 🙂

    in reply to: Hide metabox/field if post has parent #4467
    mcmaster
    Member

    I think the simplest way is to enclose the field definition in an “if” statement.

    if ( $post->post_parent ) {
        // define fields here
    }

    You may need to declare $post as a global.
    global $post;

    Donna

    in reply to: stuck on sanitizing #4141
    mcmaster
    Member

    p.s. If you looked closely, you probably figured out that the preg_match phrase doesn’t work. I ended up going in a different direction as all I really wanted to do was remove the dollar sign if someone entered it with the amount. So in case it’s helpful, here’s what I’m using:

    	$number = str_replace( '$', '', $value);
    	$number = (int)$number;
    
    in reply to: stuck on sanitizing #4140
    mcmaster
    Member

    Then I found this page: https://piklist.com/user-guide/docs/piklist_sanitization_rules/
    So I added a ‘piklist_sanitization_rules’ filter and created a rule for ‘mcw_integer’, using the same callback function:

    
    add_filter( 'piklist_sanitization_rules', 'mcw_add_sanitize_rule', 11 );
    function mcw_add_sanitize_rule ( $sanitization_rules ) {
    	$sanitization_rules['mcw_integer'] = array(
    		'callback' => 'mcw_sanitize_integer'
    	);
    	return $sanitization_rules;
    }
     
    function mcw_sanitize_integer ( $value, $field, $options ) {   
    	$number = preg_match( '/^[0-9]+$/', $value );
    	$number = (int)$number;
    	if ( isset( $options['non_negative'] ) && $options['non_negative'] && ( $number < 0 ) ) {
    		return '0';
    	} else {
    		return "$number";
    	}
    }
    

    I changed the field definition to:

    
    piklist('field', array(
    	'type' => 'text',
    	'field' => 'donation',
    	'scope' => 'post_meta',
    	'value' => '',
    	'template' => 'mcw_quantity',
    	'label' => 'Amount of Donation',
    	'sanitize' => array(
    		array(
    			'type' => 'mcw_integer',
    			'options' => array(
    				'non_negative' => true,
    			),
    		),
        ),
        'required' => false,
    ));
    

    The good news is that it does call the callback function. But it kept giving me an error message: ‘PHP Notice: Undefined index: type in /…/wp-content/plugins/piklist/includes/class-piklist-validate.php on line 304

    But of course, now that I’m reporting this, the error message has gone away. So it looks as though the second model is working.

    It would be really helpful to have one complete example that shows both ends of the process, and I would like to know what I did wrong with my first attempt.

    Thanks! 🙂

    in reply to: WYSIWYG post excerpts? #3727
    mcmaster
    Member

    Firefox hung, so I restarted it. And now the excerpt is showing up as WYSIWYG. Go figure!

    in reply to: [Request] Limit to single file #3720
    mcmaster
    Member

    Thanks for the explanation, Steve. This one’s on my wishlist, too.

Viewing 15 posts - 106 through 120 (of 125 total)