Is there a way for a plugin to add an attribute to the tag of a theme?

You can probably use the language_attributes filter (from the language_attributes() function) to add it. It should receive an output like lang=”en” and you can add to it before printing to the <html> tag: add_filter( ‘language_attributes’, function( $attr ) { return “{$attr} manifest=\”manifest.appcache\””; } ); or without a anonymous function add_filter( ‘language_attributes’, ‘wpse140730_add_manifest_to_language_attributes’ ); function wpse140730_add_manifest_to_language_attributes($output) … Read more

username_exists() function can’t be access without logging in

When using Ajax API, and you want to make the ajax callback available for non-logged users, you need to add 2 actions, “wp_ajax_{$action}” and “wp_ajax_nopriv_{$action}”. Using only the first action, the callback will be called only for logged users, using only the second it will be called only for non-logged visitors. Try this: function check_username() … Read more

Getting paginate_links() ‘end_size’ to display none

Here’s one suggestion: First we need to let paginate_links() return an array instead of a HTML list: ‘type’ => ‘array’, Then we can grab the output with: $paginate_links = paginate_links( $paginationArgs ); The plan is then to filter out the wanted links. Let’s get the current value: $c = $paginationArgs[‘current’]; We construct the search filter … Read more

Is the first item returned by get_posts() always the latest post?

Yes and Maybe Yes: According to https://developer.wordpress.org/reference/functions/get_posts/ the default is ordered by date in a descending order. Maybe: But plugins may change the query through ie hook(s) pre_get_posts. https://developer.wordpress.org/reference/hooks/pre_get_posts/ https://developer.wordpress.org/reference/classes/featured_content/pre_get_posts/

adding a filter to a shortcode?

You can change your code to this: <?php $shortcode = do_shortcode(‘[mingleforum]’); echo apply_filters(‘my_new_filter’,$shortcode); ?> and then you can interact with that filter add_filter(‘my_new_filter’,’my_new_filter_callback’); function my_new_filter_callback($shortcode){ //to stuff here return $shortcode; }

Retrieve POST data from AJAX call

Problem “Serialization” is the act of turning a data-object into a string-representation. jQuery automatically serializes the data property before sending an AJAX request. The server then deserializes the GET querystring from the URL, and the request body for POST requests before populating PHP’s request variables. Your code functioned as expected when data consisted solely of … Read more

is_admin returning false in backend in server side rendered block

If you have a server side rendered block in the backend, it is rendered via the REST API endpoint /wp/v2/block-renderer/xyz/blockname. This endpoint calls your render function. In the frontend the render function is called directly. The function is_admin() checks if a backend page was requested. In a REST API Request is no backend page, so … Read more

Pass a PHP variable to another file

The WordPress template functions don’t support passing variables (to my knowledge) by default, so you need to write your own function. For example like this, // functions.php function my_template_include_with_variables( string $path=””, $data = null ) { $file = get_template_directory() . “https://wordpress.stackexchange.com/” . $path . ‘.php’; if ( $path && file_exists( $file ) ) { // … Read more