Skip to content

Instantly share code, notes, and snippets.

View eeppo's full-sized avatar
🫡

Eeppo eeppo

🫡
  • Finland
View GitHub Profile
@Niq1982
Niq1982 / card.php
Last active July 20, 2024 17:06
Load more to WordPress blog archive using AlpineJS and Axios
<div class="card">
<?php if ($args['link']) : ?>
<a href="<?php echo esc_url($args['link']); ?>" class="global-link">
</a>
<?php endif; ?>
<div class="card-image">
<?php wp_get_attachment_image($args['image']); ?>
</div>
@todeveni
todeveni / wp_collate.php
Last active March 6, 2023 06:22
Convert WordPress collation to utf8mb_swedish_ci
<?php
if ( ! defined( 'WP_CLI' ) ) {
print "Run with wp eval-file wp_collate.php\n";
exit;
}
global $wpdb, $table_prefix;
$wp_config_path = \WP_CLI\Utils\locate_wp_config();
@andrewodri
andrewodri / remove.sql
Created February 26, 2020 18:44
Remove all users from Wordpress Multisite that do not belong to other sites
SET @site_id = 1;
SELECT user_id
FROM wp_usermeta
WHERE meta_key = CONCAT('wp_', @site_id, '_capabilities')
AND meta_value LIKE 'a:1:{s%'
HAVING user_id NOT IN (
SELECT user_id
FROM wp_usermeta
WHERE meta_key LIKE CONCAT('wp_', @site_id, '_capabilities')
@Ruzgfpegk
Ruzgfpegk / wp-perf.md
Last active April 9, 2025 09:04
WordPress Performance & Development tips
@Webkadabra
Webkadabra / brand_names_list.txt
Last active April 9, 2019 06:56
A list of randomly generated brand names (PHP)
setuzi
golaci
cobisy
ruzajy
dubevi
gikicy
gisuxy
sotypi
loxela
kugaxa
@taeo
taeo / delete_bad_usermeta.sql
Created February 22, 2019 00:38
WooCommerce - delete users with customer role and no orders (likely spam accounts)
/* Delete usermeta that nas no related user in users */
DELETE FROM wp_usermeta WHERE wp_usermeta.user_id NOT IN (SELECT ID FROM wp_users);
@Niq1982
Niq1982 / flywheel-local-xdebug-vscode.md
Last active December 17, 2022 09:33
WordPress debugging with XDebug on Flywheel Local & VSCode

Flywheel Local configuration

Flywheel Local has XDebug installed by default if you choose “Custom” instead of “Preferred” when setting up a new local environment. If you don’t know which your current site is running, you can detect it by going to ”Site Setup” tab. If you can change the PHP version there, you have the “Custom” environment running. If not, just export your site, import it back and choose “Custom”.

Now that we have the right environment, remember what PHP version you are running, open the right PHP settings file (for example /Local Sites/my_site/conf/php/7.0.3/php.ini) and add these lines in the [Xdebug] section:

xdebug.remote_enable=1
xdebug.remote_autostart=1

Save the php.ini and restart your site container in Flywheel to apply new settings.

@Niq1982
Niq1982 / debug-translations
Created July 11, 2017 09:57
Find out what WordPress translation text domains an element is using
add_filter( 'gettext', 'debug_translations', 30, 3 );
function debug_translations( $translated_text, $text, $domain ) {
if ( $translated_text ) {
$output = $translated_text;
$output .= '<span style="font-size: 18px; color: white; line-height: 1; background-color: red; width: 24px; padding: 3px; border-radius: 18px;" title="text-domain: ';
$output .= $domain;
$output .= '">�</span>';
}
return $output;
}
/**
* Add support for correct UTF8 orderby for post_title (äöå)
*
* @param string $orderby ordering clause for query
*
* @return string ordering clause for query
*/
add_filter('posts_orderby', function($orderby) use ($wpdb) {
if(strstr($orderby, 'post_title')) {
@contemplate
contemplate / functions.php
Last active May 14, 2024 23:46
WooCommerce - Allow guest checkout for certain products when Guest checkout is Disabled globally
/*--------------------------------------
Woocommerce - Allow Guest Checkout on Certain products
----------------------------------------*/
// Display Guest Checkout Field
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';