Jump to content

Where to insert wordwrap in php file


keighdesign

Recommended Posts

I want to limit the length of an author's name in a display to 10 characters - using two lines if necessary for full display. I know I can use wordwrap of some sort to do that. However, I am not sure where/how to accomplish it. Can it be inserted in the following (and if so, where/what do I insert, specifically):

 

<?php _e('Order by','authors') ?>:<br />
		<label for="authors-order-<?php echo $number; ?>-name"><input type="radio" class="radio" id="authors-order-<?php echo $number; ?>-name" name="widget-authors[<?php echo $number; ?>][order]" value="name"<?php echo 'name' == $order || '' == $order ? ' checked="checked"' : '' ?> /> <?php _e('Display name','authors' ) 
?></label>

 

NOTE: I have attached the full code in a text file if I've selected the wrong snip.

 

Thank you!

 

[attachment deleted by admin]

Link to comment
Share on other sites

UPDATE: I HAVE ATTACHED AN IMAGE FILE THAT SHOWS THE CURRENT PROBLEM IN DISPLAY

 

I want to limit the length of an author's name in a display to 10 characters - using two lines if necessary for full display. I know I can use wordwrap of some sort to do that. However, I am not sure where/how to accomplish it. Can it be inserted in the following (and if so, where/what do I insert, specifically):

 

<?php _e('Order by','authors') ?>:<br />
		<label for="authors-order-<?php echo $number; ?>-name"><input type="radio" class="radio" id="authors-order-<?php echo $number; ?>-name" name="widget-authors[<?php echo $number; ?>][order]" value="name"<?php echo 'name' == $order || '' == $order ? ' checked="checked"' : '' ?> /> <?php _e('Display name','authors' ) 
?></label>

 

NOTE: I have attached the full code in a text file if I've selected the wrong snip.

 

Thank you!

 

[attachment deleted by admin]

Link to comment
Share on other sites

So the actual problem is the size of the <select>, yes? Can you not use CSS to restrict, or even flat-out declare, its width to fit appropriately?

 

This is a widget inside the latest version of Wordpress. CSS would have to be inline. Would I add the css in this section? I am not a php coder and am hesitant to start hacking around inside it. Please advise and thank you so much for your time.

 

	function widget_authors_dropdown($args = '') {
	$args['echo'] = false;
	unset($args['feed']);
	$arr = widget_authors_order_by($args);
	$options = '';
	foreach ($arr as $author) {
		preg_match('#<a href="([^"]*)"[^>]*>([^<]*)</a>( \(([0-9]*)\))?#', $author, $matches);
		$options .= '<option value="'.htmlspecialchars($matches[1]).'">'.$matches[2].($args['optioncount'] ? ' ('.$matches[4].')' : '').'</option>'."\n";
	}
	unset($arr);
	$dropdown = '<select onchange="window.location=this.options[this.selectedIndex].value">'."\n";
	$dropdown .= '<option value="#">'.__('Select Author...', 'authors').'</option>'."\n";
	$dropdown .= $options;
	$dropdown .= '</select>';
	echo $dropdown;
}

Link to comment
Share on other sites

It worked perfectly!! Thank you!

Would I add the css in this section?

$dropdown = '<select onchange="window.location=this.options[this.selectedIndex].value">'."\n";

Right in there. For example,

 

$dropdown = '<select style="display:block;width:100%;" onchange="window.location=this.options[this.selectedIndex].value">'."\n";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.