Is it possible to change image urls by hooks?

As you want to change (use different) URL for featured image only, you can use pre_option_upload_url_path hook. // Setting the uploads directory URL function wpse_change_featured_img_url() { return ‘http://www.example.com/media/uploads’; } add_filter( ‘pre_option_upload_url_path’, ‘wpse_change_featured_img_url’ ); This hook will not change URLs permanently but it will set uploads directory to some different URL temporally. This will also not … Read more

Filter for Admin Nav Menus Drop Down

I believe the filter you want is wp_get_nav_menus: function wp_get_nav_menus( $args = array() ) { $defaults = array( ‘hide_empty’ => false, ‘orderby’ => ‘name’ ); $args = wp_parse_args( $args, $defaults ); /** * Filter the navigation menu objects being returned. * * @since 3.0.0 * * @see get_terms() * * @param array $menus An array … Read more

hook that when page is starting to load

Well, when exactly do you consider the page to be “starting to load”? get_header() is typically the first function to fire as the html of a theme is starting to generated. It fires the get_header action. Numerous hooks fire prior to that, at different points, the very earliest being muplugins_loaded I believe. wp_loaded, by the … Read more

How to use output buffering in WordPress hooked functions?

TL;DR: After the draft_to_publish hook is executed, the page is redirected, so you won’t see the echoed output. Ref: https://wordpress.stackexchange.com/a/94011/71131 I think the problem is that the draft_to_publish action saves the post, which will call a redirect request to the browser, which loads the edit page from scratch again. Then whatever whatever scripts previously echoed … Read more

Don’t delete a page if it holds users

It gives an array with objects. So in_array() won’t find anything, you have to convert it before. After you get the results from wbdb: $employees_array = array(); foreach($employees as $employee) { $employees_array[] = $employee->meta_value; } if(in_array($company, $employees_array)) { … }

Trying to understand order and frequency of action hooks firing

I’m not sure if you mean some custom login dialog, but let’s do some logging when we are on the wp-login.php page, where we fill the login form and press enter: #—————– # Page Load #1 #—————– 2015-11-24: 14:45:41 — $_SERVER: Array ( [REQUEST_URI] => /wp-login.php [SCRIPT_NAME] => /wp-login.php [DOCUMENT_URI] => /wp-login.php [REDIRECT_STATUS] => 200 … Read more

Where to add hooks in a class

Where to add hooks in a class? “In class-based object-oriented programming, a constructor (abbreviation: ctor) is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.” Source: Wikipedia. The constructor is not the place to add … Read more

Menu item added in wp_nav_menu_items filter is never highlighted

@AlexanderFarber, there are many way to attach attribute class under wp_nav_menu link. I agree with @Sumit, adding page links in Appearance > Menu WordPress take care of current-menu-item class or current_page_item class. Also, this way is best practice to handle your nav menu in the future. Create dynamic link in wp_nav_menu Since your question related … Read more