I am trying to change the words for various places in Wordpress Admin, for example, change the name of "Dashboard" to something else, but I want it to change across the entire Admin - all the occurances. I tried searching through admin files and replacing words, but this is just too much time consuming.
I don't need the words to be translatable, is there any way to do this? Thanks!
Put this code to the function.php file of your child theme:
add_filter( 'gettext', 'dirty_translate' );
add_filter( 'ngettext', 'dirty_translate' );
function dirty_translate( $translated ) {
$words = array(
// 'word to translate' => 'translation'
'Dashboard' => 'Foo',
'Add new' => 'Bar'
);
$translated = str_ireplace( array_keys($words), $words, $translated );
return $translated;
}
Just replace the translations with your own. You can add as many translations as you need. I'm using this myself - Tested and works.
Related
I want to add a dropdown for woocommerce cities.
I find a code for adding states as dropdown, but i dont know how to do this for cities. I try to make an analogy but it doesnt work.
Also, if posible i would like to shop cities based on the states, so i need a condition: if state = X then show this cities
The code for states was this:
add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
function custom_woocommerce_states( $states ) {
$states['RO'] = array(
'TL' => 'Tulcea',
'VS' => 'Vaslui',
'VL' => 'Valcea',
'VN' => 'Vrancea'
);
return $states;
}
I havent found another way to do that except through this plugin https://github.com/8manos/wc-city-select , it adds functionality so you can do something like so
add_filter( 'wc_city_select_cities', 'my_cities' );
function my_cities( $cities ) {
$cities['NG'] = array(
'LA' => array(
'Ikorodu',
'Ikeja'
),
'OY' => array(
'Ibadan',
'Saki'
)
);
return $cities;
}
Of course the snippet will be in your functions.php
Is there a way to remove the default 'uncategorized' category (from categories in Wordpress admin) upon activating my theme?
This will have to go in functions.php obviously.
As long as you have at least one other category to set as the default, you should be able to go to Settings>>Writing and change the default post category to one of your other categories. After doing this you should be able to delete Uncategorized by going to Posts>>Categories and deleting it there.
You can also change the Uncategorized default category by adding this to functions.php:
// Uncategorized ID is always 1
wp_update_term(1, 'category', array(
'name' => 'hello',
'slug' => 'hello',
'description' => 'hi'
));
as shown in this post: https://wordpress.stackexchange.com/questions/83415/remove-rename-uncategorized-category-in-wordpress
More info on wp_update_term
You can use the wp_delete_category function
<?php wp_delete_category( $cat_ID ) ?>
But you need at least 1 category in WordPress, so as long as you're create extra ones before hand you should be ok.
wp_delete_category reference page:
http://codex.wordpress.org/Function_Reference/wp_delete_category
This Works for me
add_filter( 'woocommerce_product_categories_widget_args', 'remove_uncategorized_category' );
add_filter( 'woocommerce_product_subcategories_args', 'remove_uncategorized_category' );
function remove_uncategorized_category( $args ) {
$uncategorized = get_option( 'default_product_cat' );
$args['exclude'] = $uncategorized;
return $args;
}
I'm trying to figure out a way for members on my Wordpress (Buddypress) site to pick their "favorite movies, books, etc."
It would be nice if, instead of members simply typing a list of these things, they could select from books already in the system, and add more as the please in the future.
I'm hoping that there is an easy answer to this, such as a plugin that I can use, or, at least, modify. Does anyone know of anything that I can look into?
Your title asks how to add a user profile field. Here is the code to add as many fields as you like. Once you add the field, you can easily place additional inputs or options on the custom tab page for users to enter their own favorites.
function my_test_setup_nav() {
global $bp;
$parent_slug = ‘test’;
$child_slug = ‘test_sub’;
//name, slug, screen, position, default subnav
bp_core_new_nav_item( array(‘name’ => __( ‘Test’ ),’slug’ => $parent_slug,’screen_function’ => ‘my_profile_page_function_to_show_screen’,'position’ => 40,’default_subnav_slug’ => $child_slug ) );
/* Add the subnav items to the profile */
// name, slug, parent_url, parent slug, screen function
bp_core_new_subnav_item( array( ‘name’ => __( ‘Home’ ), ‘slug’ => $child_slug, ‘parent_url’ => $bp->loggedin_user->domain . $parent_slug.’/', ‘parent_slug’ => $parent_slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen’ ) );
bp_core_new_subnav_item( array( ‘name’ => __( ‘Random Page’ ), ‘slug’ => ‘random’, ‘parent_url’ => $bp->loggedin_user->domain . $parent_slug.’/', ‘parent_slug’ => $parent_slug, ‘screen_function’ => ‘my_profile_page_function_to_show_screen234′ ) );
}
function my_profile_page_function_to_show_screen() {
//add title and content here – last is to call the members plugin.php template
add_action( ‘bp_template_title’, ‘my_profile_page_function_to_show_screen_title’ );
add_action( ‘bp_template_content’, ‘my_profile_page_function_to_show_screen_content’ );
bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
}
function my_profile_page_function_to_show_screen_title() {
echo ‘wptaskforce title’;
}
function my_profile_page_function_to_show_screen_content() {
echo ‘wptaskforce content’;
}
//random page content:
function my_profile_page_function_to_show_screen234() {
//add content here – last is to call the members plugin.php template
add_action( ‘bp_template_content’, ‘my_profile_page_function_to_show_screen234_content’ );
bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
}
function my_profile_page_function_to_show_screen234_content() {
echo ‘This is a random page.’;
}
add_action( ‘bp_setup_nav’, ‘my_test_setup_nav’ );
For my users, the word 'post' does not reflect what they are actually adding when submitting a 'post'. For them, it's a project.
I'd like to change the word 'post' everywhere it appears in the admin area to be 'project', is there a function I can add to do this?
Thanks
add this to your functions.php
add_filter('gettext', 'change_post_to_project');
add_filter('ngettext', 'change_post_to_project');
function change_post_to_project($translated) {
$translated = str_ireplace('Post', 'Project', $translated);
return $translated;
}
I am making a plugin for custom wordpress admin panel theme, I have changed most of the things as per my requirement using hooks but I am unable to change Page Heading in Admin Panel in wordpress.
I am trying this, this is working fine for me, anyone having better solution
add_filter( 'gettext', 'change_post_to_article1' );
add_filter( 'ngettext', 'change_post_to_article1' );
function change_post_to_article1( $translated )
{
$translated = str_replace( 'Users', 'Customers', $translated );
$translated = str_replace( 'Add New User', 'Add New Customer', $translated );
return $translated;
}
I'm not sure how is your Admin Panel, but you can try this
array( "name" => "Heading",
"desc" => "Select heading style",
"id" => $shortname."_style",
"type" => "select",
"options" => array("heading.css", "heading2.css"),
"std" => ""),
Where heading.css is your setting file. In this case you have a special css file ore more, where you can setup your heading.
Tell me if is ok!
Like i said, creating a Wordpres Theme Admin Panel it's not so easy, but they are a lot of tutorials on internet. After a few days of searching i finally created the theme admin panel.
I will share this:
http://5wpthemes.com/blog/how-to-create-a-wordpress-theme-admin-panel/