Wordpress: Always expanded menus in dashboard / Remove minimize menu icons - wordpress

Trying to modify the menu in the dashboard a bit.
I'm trying to remove the toggle option everywhere it's present, and find someway to force the menus to always be expanded, is this possible? (toggle button: http://dl.dropbox.com/u/3618143/toggle.png)
Also want to remove the minimize option (which lets you only show icons in the menu bar). I've been able to remove the actual icon, but the functionality is still there (invisible link). So removing the actual image is not the problem, I've managed to remove that, the functionality however is still there.
(http://dl.dropbox.com/u/3618143/minimize.png)
Thanks in advance

Have the same need: remove the "un/fold" functionality from the WP admin menu bar, to remove clutter, but without tinkering with the source file.
I found out in wp-admin/menu.php that the separators are stored in index 4,59,99.
Here is the function to add to your functions.php
function pxln_remove_menu_items() {
global $menu;
//an array with menus to remove (use their title)
$restricted = array(__('Posts'),__('Links'), __('Comments'), __('Media'), __('Separator'));
// keys of the unfolders
unset($menu[4]);
unset($menu[59]);
unset($menu[99]);
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)) {
unset($menu[key($menu)]);
}
}
}
add_action('admin_menu', 'pxln_remove_menu_items');

I don't know where exactly the php file to edit it.
But you can use Firebug from Firefox extension, and find the html code to render the toggle option or separator then delete it.
Example: For separator html code is like this:
<li class="wp-menu-separator"><br></li>
Wordpress use cookies to store menu setting, you need to find it and set it manually.

Related

How do I add the navigation label of a link to a data replace function in order to change all of the links in a menu in WordPress?

I'm trying to create a cool hover text effect for my navigation menu links. The tutorial that I found is here:
https://css-tricks.com/css-link-hover-effects/
The one that I'm trying to do is "The Text Swappin' Link Hover Effect". There's a demonstration of what I'm trying to accomplish there.
This is a page from the website I'm developing. If you look up top, that's the navigation menu I'm trying to update:
https://sciencexfantasy.com/the-fundamentals-of-fiction-writing/
Immediately I ran into the issue of trying to add a data replace to my html in order to change the name of the link in the transition. Since I'm using WordPress, I can't access the html code of the menu. The theme simply adds the menu for me.
I didn't know how to add the data replace to the html so I found a resource that allows me to add a class to each link and then input data replace with the value of the data replace.
This is the code I found for that. I changed the name of the class to 'shifting-link' and updated my menu so that each menu item has that class.
I put this code in the theme functions file:
add_filter( 'nav_menu_link_attributes', function ( $atts, $item, $args ) {
if ( 'shifting-link' === $item->classes[0] ) {
$atts['data-replace'] = '';
}
Now, all I'm trying to do is put the name of the link (the navigation label) in the data replace attribute so that it replaces the name of the link with the same exact name of the link. I don't want it all to say the same thing or something generic like "Go!" or "Follow This Link".
I want the data replace for the "Amber" link to say "Amber", "Craft" to say "Craft", and so on.
I'm not good with PHP so I don't know how to insert the variable of the navigation label of the link in the data replace. I tried the variable $item but I got an error. I just have no clue how to do this and I'm not sure how to phrase the Google search either so I figured I would ask here.
Can anyone help me?

Hide page sections based on user role in Visual Composer

I am trying to hide certain page sections based on user role in Visual Composer by adding Custom Content Shortcode in two text blocks. The first text block is at the top of the content I want to hide to all but admins and contains:
[is role=administrator]
The second text block, at the bottom of the content I want to hide, contains the closing tag,
[/is]
This is doing what it's supposed to and hiding the content, however, Visual Composer doesn't seem to like it, and VC shortcode winds up getting outputted to the page for admins, i.e. [/vc_column]. I can't get it to not display the VC shortcode. It's strange too that it only outputs the shortcode for admins.
If there is a different or better way to do what I'm trying to accomplish, I'm open to any solutions! I just want certain page sections to only be visible to admins.
You could use the header function to use Jquery to remove the elements via css class for each user.
Below is not a tested solution but can be a way to achieve what you wanted but not sure how to remove completely the output source code only hide it.
This can be added to the function file or built into a plugin.
function insert_header()
{
// Check what user role
global $current_user;
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
//return $user_role;
// Check if the user has role
if($user_role == "editor")
{
// inject jQuery or css to remove the elements by class
}
}
add_action('wp_head','insert_header');

issues replacing link values on wordpress

I have a little issue with the replacement of the <a> values, I have this code:
$('a').each(function() {
var $this = $(this),
aHref = $this.attr('href'); //get the value of an attribute 'href'
$this.attr('href', aHref.replace(location.host,''+location.host+'/'+plang+''));
});
What am I try to do?
I am tring to replace all the links like this: http://example.com/?p=1 to http://example.com/es/?p=1 the code works fine for all the static links, like the menu, the logo link, the footer links and the pagination, but don't work for the post or pages links, is any other way for make that change?
The Website use the google translate jQuery script, and that is why I need change the language using: /en/?p=1 or /fr/?p=1, etc, etc.
Can't you adjust it in wp-config.php? And yes, you can also do this dynamically (despite the values being constant from the point on where you define them):
define('WP_SITEURL', ...);
define('WP_HOME', ...);

Wordpress show sub menu items on index page

I am using wordpress and on the page "sidebar.php" I have the following code:
<?php wp_list_pages('post_type=wiki&depth=1'); ?>
It works great but what I need to do it that what I click on a Menu item on the sidebar I need the sub items to display on the main page.
UPDATE:
What I basically need to do is to have the first level items on the left (As it currently is), and when those links are clicked then the sub items of those items will be listed on the index.php (main page).
I am using the wp-wiki plugin to display the pages as wiki pages but the actual but the list is the same, just showing as a different type:
post_type=wiki
Can anyone help please?
Thanks
<?php
wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->ID.'&depth=0');
?>
There's several ways you can accomplish this. WordPress actually has an example of exactly what you're looking to do in the Codex. (link - the last example in that section, right above the "List subpages even if on a subpage" heading)
There's several ways to do this though - that's just one example. But that code above, you just pop into your sidebar.php file. You can also create a widget out of it. And as someone else mentioned, you can use the new menu system for WordPress (but you can indeed, make it dynamic.) But the above example in the Codex is the simplest method.
Actually, an easier method would be just to list all subpages and use CSS to hide and show the child items based on what page you're on. The classes are already set up for you. Just view your source code and you can see it. So you'd do something like:
`li ul.children {display:none; }
li.current_page ul.children { display:block; }`
and variations thereof.
What about using the new menu function in wp 3?
That way you could include your type with any sub page you want (won't be dynamic though) and then add your favorite javascript or good css to show those sub-pages.

Drupal Zen sub theme

New to php and drupal. I set up drupal and trying to customize the zen theme. Also setup Netbeans for debuggin. Everything is fine, but the menu variables are not filled as expected.
In page.tpl.php, there is a condition, <?php if ($primary_links || $navigation): ?> , which prints main menu if evaluates true. I get primary_links empty, so the menu doesn't print. According to the css provided by the zen theme, below ids should be used for customization.
/*
* Primary and Secondary menu links
*/
#main-menu {
}
#secondary-menu {
}
I may add style elements looking through firebug, but the above id may be the right place to do it. So, why primary link variable is empty for me?
thanks.
The first thing that comes to mind is that, maybe, you haven't assigned anything to the primary links list. Have you?

Resources