Skip to content

Instantly share code, notes, and snippets.

View n1k1c4's full-sized avatar
🌝

Nikita Vyatkin n1k1c4

🌝
View GitHub Profile
@n1k1c4
n1k1c4 / show_template_file_name.php
Last active July 31, 2017 10:22
WordPress - Show template file name
<?php if (current_user_can('administrator')) : ?>
<div class="for-develop" style="position: fixed; min-width: 15%; height: 32px; background-color: #E91E63; top: 0; left: 750px; z-index: 100000; color: #fff; text-align: center; line-height: 1.8;">
<?php global $template; echo basename($template); ?>
</div><!-- /.for-develop -->
<?php endif; ?>
@n1k1c4
n1k1c4 / show_the_number_of_queries_and_time.php
Created July 11, 2017 06:12
WordPress - Show the number of queries and time
<pre><?php echo $wpdb->num_queries; ?>q, <?php timer_stop(1); ?>s</pre>
@n1k1c4
n1k1c4 / wp_replace_url.sql
Created July 11, 2017 06:15
WordPress - Replace URL in database (SQL query)
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://old', 'http://new') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://old', 'http://new');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://old','http://new');
UPDATE wp_posts SET guid = REPLACE (guid, 'http://old', 'http://new');
UPDATE wp_comments SET comment_content = REPLACE (comment_content, 'http://old', 'http://new');
UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url, 'http://old', 'http://new');
DELETE a,c FROM wp_terms AS a
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id
LEFT JOIN wp_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id
WHERE c.taxonomy = 'product_cat'
DELETE a,c FROM wp_terms AS a
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id
LEFT JOIN wp_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id
WHERE c.taxonomy = 'product_tag';
DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_posts WHERE post_type IN ('product','product_variation');
DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%');
DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%';
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL
@n1k1c4
n1k1c4 / media.css
Created June 1, 2021 14:11
media query retina / no retina
@media only screen and (-webkit-min-device-pixel-ratio: 1) {
&::before {
background-image: url("./assets/bg.jpg");
}
}
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (-o-min-device-pixel-ratio: 2/1),
only screen and (min-resolution: 192dpi),
only screen and (min-resolution: 2dppx) {
plugin(({ addUtilities, variants, theme, e }) => {
const colors = theme("colors")
const generateColors = (e, colors, prefix) =>
Object.keys(colors).reduce((acc, key) => {
if (typeof colors[key] === "string") {
return {
...acc,
[`${prefix}-${e(key)}`]: {
"-webkit-text-fill-color": colors[key],
},