ThomDJ
Forum Replies Created
-
Forum: Plugins
In reply to: [Highlight Search Terms] Create compatibility with WP Grid BuilderHi there,
I’ve made it a separate plugin for now, so no worries about anything being overwritten. It only utilizes mark.js, not the added functionalities added by hlst-extend, so better integration is definitely possible. The plugin folder is wp-grid-builder and the main file is wp-grid-builder.php. I can send you a copy of the plugin if that helps?
Forum: Plugins
In reply to: [Highlight Search Terms] Create compatibility with WP Grid BuilderThat makes sense! I noticed it had Search & Filter Pro compatibility, and plans for FacetWP, hence the question.
Anyway, I’ve been tinkering with it for the last couple of days to make it work myself, and it does!
document.addEventListener('DOMContentLoaded', function() { const container = document.querySelector('.wpgb-viewport'); function getQueryParamFromURL() { const urlParams = new URLSearchParams(window.location.search); for (const [key, value] of urlParams) { if (key.startsWith('_') && key.length > 1) { return value; } } return ''; // Returns empty if no matching param is found } let lastSearchTerm = ''; let lastHeight = container.style.height; function highlightText(force = false) { const searchTerm = getQueryParamFromURL(); if (!searchTerm || (searchTerm === lastSearchTerm && !force)) return; lastSearchTerm = searchTerm; const elementsToMark = container.querySelectorAll('.wpgb-card'); const instance = new Mark(elementsToMark); instance.unmark({ done: function() { instance.mark(searchTerm, { element: 'mark', className: 'highlight' }); } }); } const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { if (mutation.attributeName === 'style') { let newHeight = container.style.height; if (newHeight !== lastHeight) { lastHeight = newHeight; highlightText(true); } } }); }); observer.observe(container, { attributes: true, attributeFilter: ['style'] }); highlightText(); // Initial call to highlight any existing content });
$searchTerm = ''; foreach ($_GET as $key => $value) { if (strpos($key, '_') === 0 && strlen($key) > 1) { $searchTerm = sanitize_text_field($value); break; } } wp_localize_script('wpgb-highlight-script', 'wpgbParams', array( 'searchTerm' => $searchTerm ));
Alright, I submitted a ticket, thanks!
Forum: Plugins
In reply to: [Temporary Login Without Password] Add custom post type support?Also, the plugin auto-generates a username based on the first and last name, but doesn’t remove spaces if a person has more than one first or last name. Perhaps it would be useful to also remove spaces automatically when generating the username.
/** * Create a random username for the temporary user * * @param array $data * * @return string */ public static function create_username( $data ) { $first_name = isset( $data['user_first_name'] ) ? $data['user_first_name'] : ''; $last_name = isset( $data['user_last_name'] ) ? $data['user_last_name'] : ''; $email = isset( $data['user_email'] ) ? $data['user_email'] : ''; $name = ''; if ( ! empty( $first_name ) || ! empty( $last_name ) ) { // Remove spaces from first and last names and concatenate them $name = str_replace( array( '.', '+', ' ' ), '', strtolower( trim( $first_name . $last_name ) ) ); // Transliterate special characters to ASCII equivalents $name = iconv('UTF-8', 'ASCII//TRANSLIT', $name); // Remove any non-alphanumeric characters $name = preg_replace('/[^a-zA-Z0-9]/', '', $name); } else { if ( ! empty( $email ) ) { $explode = explode( '@', $email ); // Use portion before '@' symbol as name and remove spaces $name = str_replace( array( '.', '+', ' ' ), '', $explode[0]); } } if ( username_exists( $name ) ) { $name = $name . substr( uniqid( '', true ), - 6 ); } $username = sanitize_user( $name, true ); /** * We are generating WordPress username from First Name & Last Name fields. * When First Name or Last Name comes with non-latin words, the generated username * might be non-latin, and the sanitize_user function might discard it, resulting * in the user not being generated. * * To avoid this, if this situation occurs, we are generating a random username * for this user. */ if ( empty( $username ) ) { $username = self::random_username(); } return sanitize_user( $username, true ); }
Forum: Plugins
In reply to: [Temporary Login Without Password] Add custom post type support?Changing the function of class-wp-temporary-login-without-password-common.php at line #1121 to the following achieves what I’m looking for:
/** * Get all public post types that are not excluded from search * Group posts by post type and sort them by post type name * Display post type names in the language used in WordPress * * @param string $selected * * @since 1.6.9 */ public static function tlwp_dropdown_redirect_to( $selected = '' ) { // Get all public post types that are not excluded from search $post_types = get_post_types( array( 'public' => true, 'exclude_from_search' => false, ), 'objects' ); // Array to store all posts from public post types grouped by post type $items_by_type = array(); // Loop through each public post type foreach ( $post_types as $post_type ) { // Get posts for the current post type $posts = get_posts( array( 'post_type' => $post_type->name, 'post_status' => 'publish', 'posts_per_page' => -1 ) ); // Add each post to the items_by_type array under its post type foreach ($posts as $post) { $items_by_type[$post_type->name][] = array( 'ID' => $post->ID, 'post_title'=> $post->post_title, 'post_type' => $post_type->name ); } } // Start building the dropdown HTML $output = ''; // Loop through each post type foreach ($items_by_type as $type => $items) { // Sort items alphabetically by post title within each post type usort($items, function($a, $b) { return strcmp($a['post_title'], $b['post_title']); }); // Get translated post type name $post_type_label = get_post_type_object($type)->labels->name; // Start an optgroup for each post type $output .= "<optgroup label='" . esc_attr( $post_type_label ) . "'>"; foreach ($items as $item) { // Preselect specified item $is_selected = ( $selected == $item['ID'] ) ? 'selected="selected"' : ''; // Add an <option> element for each item $output .= "\n\t<option value='" . esc_attr( $item['ID'] ) . "' $is_selected>" . esc_html( $item['post_title'] ) . "</option>"; } $output .= "</optgroup>"; } // Echo the generated HTML echo $output; }
- This reply was modified 11 months, 2 weeks ago by ThomDJ.
Can I email you? It’s not a publicly accessible site.
Forum: Plugins
In reply to: [WP Fastest Cache] Cache Url with QueryStringPerfect, thank you!
Forum: Plugins
In reply to: [Cache Warmer] Setting up a cronjobYes, when using Rank Math sitemap, it is working as intended! ??
Forum: Plugins
In reply to: [Autoptimize] Exclude all scripts from plugin (via Regex)?Thanks, that did the trick! ??
Forum: Plugins
In reply to: [WP Fastest Cache] Cache Url with QueryStringAwesome! So /tag/?_keyword_filter=banana and /tag/?_keyword_filter=apple would also be served separate cached pages?
Forum: Plugins
In reply to: [WP Fastest Cache] Cache Url with QueryStringIf not, would it be possible to Rewrite the Query String to a Path and subsequently have it be cached separately? (So rewrite it to https://YOURDOMAIN.COM/tag/example)
Hi, this is the case with WP Grid Builder as well, even when adding request=”remote” to the shortcode. The content does not show up.
Forum: Plugins
In reply to: [Cache Warmer] Setting up a cronjobHi, I already changed the sitemap plugin on this website, but the one I used was this one: XML Sitemap & Google News.
Hello, my comment was premature, because your plugin already removes this meta tag, even though it’s not a separate option. Sorry!
Forum: Plugins
In reply to: [Cache Warmer] Setting up a cronjobGoing back to my previous post, it seems to be something specific to this sitemap plugin, as it works perfectly fine using another plugin.