Solved

Wordpress Filters

Posted on 2014-09-13
8
296 Views
Last Modified: 2014-09-13
I have attempted to ask this question before but I don't think I was being clear enough and I also know just enough to make me dangerous!
I want to create a Wordpress Filter to change a line of code within a Core Function in Wordpress / Woocommerce.

The Worpress / WooCommerce function is as follows:
	public function edit_columns( $existing_columns ) {
		$columns = array();

		$columns['cb']               = '<input type="checkbox" />';
		$columns['order_status']     = '<span class="status_head tips" data-tip="' . esc_attr__( 'Status', 'woocommerce' ) . '">' . esc_attr__( 'Status', 'woocommerce' ) . '</span>';
		$columns['order_title']      = __( 'Order', 'woocommerce' );
		$columns['order_items']      = __( 'Purchased', 'woocommerce' );
		$columns['shipping_address'] = __( 'Ship to', 'woocommerce' );

		return $columns;
	}

Open in new window

I have followed the directions offered by Wordpress but it is not working for me.  I want to Replace The Word "Order" with the words "My Number"  on line: 6

Here is what I have that is not working. (This filter is my Custon-Functions.php file)
function filterAdminLabels( $existing_columns ) {
	$labels = array('Order');
	$existing_columns = str_ireplace($labels, 'My Number', $existing_columns);	
}
add_filter ( 'edit_columns', 'filterAdminLabels', 2 );

Open in new window

0
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 15

Expert Comment

by:eemit
ID: 40321146
Add this line:
return $existing_columns;

Open in new window

after the line:
$existing_columns = str_ireplace($labels, 'My Number', $existing_columns);

Open in new window

0
 
LVL 7

Author Comment

by:rgranlund
ID: 40321163
I tried that and nothing Changed.  However, I did discover I was trying to hook into the wrong function.  Here is the correct function and I want to replace the word Order with My Policy:
Wordpress Function
	public function shop_order_columns( $existing_columns ) {
		$columns                     = array();
		$columns['cb']               = '<input type="checkbox" />';
		$columns['order_status']     = '<span class="status_head tips" data-tip="' . esc_attr__( 'Status', 'woocommerce' ) . '">' . esc_attr__( 'Status', 'woocommerce' ) . '</span>';
		$columns['order_title']      = __( 'Order', 'woocommerce' );
		$columns['order_items']      = __( 'Purchased', 'woocommerce' );
		$columns['shipping_address'] = __( 'Ship to', 'woocommerce' );
		$columns['customer_message'] = '<span class="notes_head tips" data-tip="' . esc_attr__( 'Customer Message', 'woocommerce' ) . '">' . esc_attr__( 'Customer Message', 'woocommerce' ) . '</span>';
		$columns['order_notes']      = '<span class="order-notes_head tips" data-tip="' . esc_attr__( 'Order Notes', 'woocommerce' ) . '">' . esc_attr__( 'Order Notes', 'woocommerce' ) . '</span>';
		$columns['order_date']       = __( 'Date', 'woocommerce' );
		$columns['order_total']      = __( 'Total', 'woocommerce' );
		$columns['order_actions']    = __( 'Actions', 'woocommerce' );

		return $columns;
	}

Open in new window

My Function:
function filterAdminLabels( $existing_columns ) {
	$labels = array('Order');
	$existing_columns = str_ireplace($labels, 'Policy Number', $existing_columns);	
	return $existing_columns;
}
add_filter ( 'shop_order_columns', 'filterAdminLabels', 2 );

Open in new window


I followed the instructions but nothing happens.  What do you think I am doing wrong?
0
 
LVL 15

Expert Comment

by:eemit
ID: 40321177
I think you should use the filter: 'manage_edit-shop_order_columns'
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Author Comment

by:rgranlund
ID: 40321179
I don't understand, please explain
0
 
LVL 15

Expert Comment

by:eemit
ID: 40321185
add_filter ( 'manage_edit-shop_order_columns', 'filterAdminLabels', 2 );
0
 
LVL 15

Accepted Solution

by:
eemit earned 500 total points
ID: 40321208
Try this:
add_filter ( 'manage_edit-shop_order_columns', 'filterAdminLabels', 11 );
function filterAdminLabels( $existing_columns ) {
	$existing_columns['order_title'] = __( 'Policy Number', 'woocommerce' );

	return $existing_columns;
}

Open in new window

0
 
LVL 7

Author Closing Comment

by:rgranlund
ID: 40321222
WOW!  Thanks for pointing out the filter. Very powerful.  Thanks so much for taking the time to answer that question.  i have been working on this issue for almost 6 hours!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question