Prevent “main” WPMU site_url() being returned in functions

Since “WordPress MU is no longer under active development as a separate product“, I don’t recommend using it. Instead I recommend using the setup described in this answer. It’s highly configurable you can choose what WordPress files you want on all your WordPress sites and what you want to store separately from each other WordPress … Read more

Can the new 4.8v text widget visual editor be removed?

The answer is mostly no. The “enhanced” text widget was designed to work like the post editor as much as possible, including autop which might break whatever HTML that can not stand the conversion of lines into paragraphs. Several people have released plugins to restore the former functionality, but 4.8.1 will also include an “code” … Read more

Set JPEG compression for specific custom image sizes

The ‘jpeg_quality’ filter hook functions accept two arguments: $jpeg_quality and $function which is the function from within the filter hook is fired and can be either image_resize or wp_crop_image. So there is no way to selectively set the quality of .jpeg images according to image size from this filter hook function. However, you still can … Read more

Use AJAX in shortcode

First off, this is very borderline within the scope of WPSE, it at all. Apart from the shortcode to trigger the initial HTML output, this is really just AJAX. Anyhow, that being said, this is how it’s done: The PHP Assuming that the above PHP snippet you supplied is functional, place the following in a … Read more

Trying to use add_action and do_action with parameters

You are using it wrong. add_action: attachs a function to an action hook. In your code, you are attaching alter_item funtion to admin_menu action hook. So, when admin_menu action happens, alter_item function is executed. According to codex, no parameters are passed to functions attached to admin_menu. So, the parameters your are trying to use in … Read more

Is it ok to use a function to output the text domain name in a wordpress theme

No, this is not okay. NO NO NO. Here’s my favourite Otto quote: Inside all translation functions, no PHP variables are allowed in the strings, for any reason, ever. Otto explains this in more detail, but the simple way to say it is that translation calls are parsed, not executed . So your variable (let … Read more

Get menu object from theme_location

This method looks like what you’re looking for, using get_nav_menu_locations() and get_term(): $theme_locations = get_nav_menu_locations(); $menu_obj = get_term( $theme_locations[$theme_location], ‘nav_menu’ ); $menu_name = $menu_obj->name; (See the link for the whole thing wrapped up in a custom function; the above code just highlights the relevant WP functions for getting what you’re after.)

get php variable from functions php and echo it in theme template files [closed]

If you don’t have access to the value, it’s likely a scope issue. Make sure you globalize it first: <?php global $fb_app_id; echo $fb_app_id; ?> Alternatively I’m not a fan of global variables, so the alternative I recommend is using WordPress’ built-in filter mechanism. You add the filter in your functions.php file and apply it … Read more