What is an arbitrary URL?

Arbitrary by definition is: Based on random choice or personal whim, rather than any reason or system. WordPress sometimes generates URLs automatically and systemically. For example, whenever you create a new WordPress page it will, by default simply generate a URL based on the slug of the page title. example.com/my-page-title/ We can change this but … Read more

Cache WP remote_get HTTP Response using Transients

function display_api_response() { $body = get_transient( ‘my_remote_response_value’ ); if ( false === $body ) { $api_url = “https://randletter2020.herokuapp.com”; $response = wp_remote_get($api_url); if (200 !== wp_remote_retrieve_response_code($response)) { return; } $body = wp_remote_retrieve_body($response); set_transient( ‘my_remote_response_value’, $body, 5*MINUTE_IN_SECONDS ); } if (‘a’ === $body) { echo ‘A wins’; } else { // Do something else. } } add_action(‘init’, … Read more

MITM risk of not sanitizing?

This is the official answer from the WordPress Plugin Review Team: PHP runs processes one at a time. If step 1 is “Validate” and step 2 is save, then between step 1 and 2 is where a MITM happens. Now. You may be thinking “But come on, nothing could possibly happen there! That’s too fast!” … Read more

add mediaelement.js plugins into WordPress video player control bar

You can alter the mediaelement.js feature-set using the mejs_settings hook. Settings Overview Defaults are: playpause, current, progress, duration, tracks, volume, fullscreen. Add the plugin to the array as needed to extend the features. add_filter(‘mejs_settings’, function ($settings) { $settings[‘features’] = array(…,’jumpforward’); return $settings; }); Make sure to enqueue the plugin itself: wp_enqueue_script( ‘mejs-plugin-name’, ‘path_to_plugin_file’, array(‘wp-mediaelement’), null, … Read more

How to pull code snippet from functionality plugin?

You’re trying to echo <?php tags, but that won’t work: they won’t be processed. Instead you need to replicate that logic in PHP statements in your function instead. Here’s a partial answer: function epf_extra_buttons( $post_ID ) { // TODO: where does $es_settings come from? $encoded_permalink = urlencode(get_the_permalink()); if ( $es_settings->share_facebook ) { echo ‘<a class=”a2a_button_facebook” … Read more