I’m confused about URL sanitization in meta boxes

Choice between esc_url and esc_url_raw depends on the use you have to do with the url. If you have to use the url to display inside html use esc_url, E.g.: $my_link = get_post_meta( $post->ID, ‘mod_modbox_link’, true ); echo ‘<a href=”‘ . esc_url($my_link) . ‘”>Open link</a>’ esc_url_raw should be used for any other use, where the … Read more

How to make menu items active based on hash

This can be accomplised fairly easy by checking the URL then setting the appropriate link to active. That can be accomplished by the following… var hash = window.location.hash.substr(1); // Get the text after the hash $(‘a[href=”#’ + hash + ‘”]’).addClass(‘active’); // Set the correct link to active However, there are some things to consider. Someone … Read more

Callback URL in WordPress

That’s pretty simple, just use your website home url 🙂 After that, just fire an action when the page is loaded via POST HTTP method and hook with a callback. add_action( ‘wp_loaded’, function() { if ( $_SERVER[‘REQUEST_METHOD’] === ‘POST’ ) { // fire the custom action do_action(‘onchangeapi’, new PostListener($_POST)); } } ); And now the … Read more

Get url from file uploaded in Media Library

If understand your question correctly, I think this can get the job done. Use get_attachment_link instead of wp_get_attachment_url and then echo the title. <?php $attachment_id = 2582; $attachment_page = get_attachment_link( $attachment_id ); ?> <a href=”https://wordpress.stackexchange.com/questions/255020/<?php echo $attachment_page; ?>”><?php echo get_the_title($attachment_id ); ?></a>