How to add new embed handler not supported by oembed?

Pretty sure it’s the fact you’re trying to use the regex pattern in your sprintf call, when you should be using… well, a sprintf format: $embed = sprintf( ‘<iframe class=”openload-video” src=”https://openload.co/embed/%s” scrolling=”no” frameborder=”0″ width=”700″ height=”430″ allowfullscreen=”true” webkitallowfullscreen=”true” mozallowfullscreen=”true”>></iframe>’, esc_attr( $matches[1] ) ); Note that you’re not using www in your embed url: https://openload.co/f/onU1gT5mkJ8/A_date_with_Lazar_Angelov.mp4 as expected … Read more

Get Current User info using wp_localize_script, in functions.php

If you read about this action here. You will see that this hook provides access to two parameters, $user->user_login (string) and $user ( WP_User ). Using it like this you will see all the info you have access to: function add_to_login($user_login, $user) { echo “<pre>”.print_r($user, true).”</pre>”; } add_action(‘wp_login’, ‘add_to_login’, 10, 2); But after a little … Read more

How To Remove Duplicate Menu Locations

You register an array of four menus. If you reformat your code, you will see it. […] array( ‘primary-nav’, __( ‘Primary Menu’), ‘footer-nav’, __( ‘Footer Menu’) ); […] Adapt your code to an array with custom keys and you will be fine: […] array( ‘primary-nav’ => __( ‘Primary Menu’), ‘footer-nav’ => __( ‘Footer Menu’) ); … Read more

CSS for menu item added via functions.php

Normally, menu items are rendered as an <li> tag with an <a> tag inside. You could simply wrap $todaysdate in an anchor so that this item will be styled like the others: add_filter(‘wp_nav_menu_items’,’add_todaysdate_in_menu’, 10, 2); function add_todaysdate_in_menu( $items, $args ) { if( $args->theme_location == ‘header-menu’) { $todaysdate = date(‘l jS F Y’); $items .= ‘<li … Read more

How does this function get the id of the most recent post?

prepare_payment() is calling wp_get_recent_posts() which returns an array of post by default. Only one post is being returned in this case, due to the $numberposts parameter being set to 1. $recent_posts holds the array of posts returned by wp_get_recent_posts(). The following line is setting $thePostID to the ID of the first post in the $recent_posts … Read more

how to add an image to the footer?

Sounds like several different pointers may be useful: Are you working on a theme that was custom developed for your website? If not, you should create a child theme so that anytime the parent theme receives an update, your changes won’t be overwritten. The image you’re trying to add should either be uploaded through WordPress’s … Read more

How do I pass arguments for multiple functions hooked to a single action?

The value for the default output should be passed to do_action() as the second parameter. E.g.: do_action( ‘my_action’, ‘<p>Default output</p>’ ); Note that the above code will not actually output anything. It’s just going to fire the callbacks attached to the my_action hook and it will pass ‘<p>Default output</p>’ to those functions. You can modify … Read more

wp_validate_logged_in_cookie

wp_validate_logged_in_cookie() comment from source: /** * Validates the logged-in cookie. * * Checks the logged-in cookie if the previous auth cookie could not be * validated and parsed. * * This is a callback for the {@see ‘determine_current_user’} filter, rather than API. * * @since 3.9.0 * * @param int|bool $user_id The user ID (or … Read more