How to edit page heading in wordpress admin panel? - wordpress

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/

Related

Rename plugin name in Wordpress Dashboard Menu

I have tried a lot of suggestions on different posts here, but none of them seem to work for me.
I want to rename the name of a plugin on the dashboard menu on my Wordpress site. The name of the plugin is Sensei LMS and the path of the plugin folder is /plugins/sensei-lms.
I'd appreciate if someone helps me with some code that I can use to rename this. Thank you
I've used this tutorial in the past.
In your case, it would be:
function my_renamed_admin_menu_items() {
global $menu;
// Define your changes here
$updates = array(
"Sensei LMS" => array(
'name' => 'New Menu Name'
),
"Another Menu Name" => array(
'name' => 'Another New Name'
)
);
foreach ($menu as $k => $props) {
// Check for new values
$new_values = (isset($updates[$props[0]])) ? $updates[$props[0]] : false;
if (!$new_values) continue;
// Change menu name
$menu[$k][0] = $new_values['name'];
}
}
add_action('admin_init', 'my_renamed_admin_menu_items');

ACF field to create sets of pages when saved

I have an odd request, i'm not sure if this is even possible. But i'll try to work out the process below, and if anyone can help me work this out that would be amazing!
Ideally the process is as follows:
Admin goes to parent options page, within the options page there is a repeater field, called add new company. This will just be a field with a title.
Admin fills in field and presses save. This will generate a sub options page with that name, within the options field, there will be a set of fields like logo, a colour picker and some text fields (these could be a set of fields from within ACF if thats possible).
Also when this original Repeater Field is made/saved a set of pages is generated from a set of templates. Essentially using the name from the repeater field to be the main page title for the top level page and all the sub pages below are just dynamically generated. They don't need to have anything different about them, they just need to generate from a set of page templates. It needs to be able to associate with the newly generated company bits from the sub options field.
This will then essentially give the admin a new set of pages which will use the new options logo / colours etc. It would almost need to generate a new set of templates based off the master templates to dynamically make sure it picked up the correct information from the sub options page.
I'm not sure if this is possible, I have seen it work elsewhere on another job I have worked on (not exactly the same as the above but similar), but I can't work out the process to make it work sadly, as I have a horrid feeling that there is some complex bits within the database going on to do the duplication dynamically.
My other option is to run everything as a WordPress Multisite but I was trying to avoid that if possible on this occasion, but I may have to use Multisite to achieve the above.
If anyone can help me work this out that would be amazing!
Thanks in advance for any help :)
You should be able to plug into the save_post action and create new subpages from there.
add_action( 'save_post', 'create_sub_pages' ); //Plug into save_post action
//Function create sub_pages
function create_sub_pages($post_ID) {
//Repeater field name
$repeater_field_array = get_field('repeater_field_name');
//Loops through all of the items in the repeater field
foreach($repeater_field_array as $key => $value) {
//Check to see if there is already a sub page with that post name
$child_pages = get_pages(array( 'child_of' => $post_ID ));
$child_page_exists = false;
foreach($child_pages as $pages) {
if ($pages->post_title === $key) {
$child_page_exists = true;
}
}
//If not, set up the creation of the new post
if ($child_page_exists === false) {
$new_page_title = esc_html__( $key );
$new_page_content = '';
$new_page = array(
'post_type' => 'page',
'post_date' => esc_attr( date('Y-m-d H:i:s', time()) ),
'post_date_gmt' => esc_attr( date('Y-m-d H:i:s', time()) ),
'post_title' => esc_attr( $new_page_title ),
'post_name' => sanitize_title( $new_page_title ), //This could from the sub_field in the repeater
'post_content' => $new_page_content,
'post_status' => 'publish',
'post_parent' => $post_ID,
'menu_order' => $new_page_order
);
$new_page_id = wp_insert_post( $new_page );
update_post_meta( $new_page_id, '_wp_page_template', $value );
}
}
}
Again, this is just a spitball since there was not much code to review, but it could help you get going in the right direction.

Wordpress replace all ocurrances of the string in admin

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.

How to show my plugin in WordPress?

can any one help to solve a problem?
Just For example:
If I have one site wpnpl.com.np
I wannt to give access to the files of a plugin like if they type
wpnpl.com.np/npl they will access the features of the plugin
How to do this???Any Idea
First create plugin short code in your plugin core file
function bartag_func( $atts ) {
$atts = shortcode_atts( array(
'foo' => 'no foo',
'baz' => 'default baz'
), $atts, 'bartag' );
return "foo = {$atts['foo']}";
}
add_shortcode( 'bartag', 'bartag_func' );
After that create a page in wp-admin with slug npl and content with
[bartag foo="bar"]

Changing the word 'post' to 'project' in WordPress

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;
}

Resources