Skip to content

Instantly share code, notes, and snippets.

// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}
@maxyudin
maxyudin / 2018-https-localhost.md
Last active October 21, 2020 15:14 — forked from cecilemuller/2019-https-localhost.md
Как создать сертификат HTTPS для доменов и субдоменов на localhost

How to create an HTTPS certificate for localhost domains

Как создать HTTPS сертификат для доменов и субдоменов на localhost

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only. Этот пример служит для создания сертификатов для виртуальных хостов (доменов и поддоменов) на локалхосте.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial). Нельзя использовать этот пример для сайтов «в продакшне», для них есть Let's Encrypt (Урок).

@maxyudin
maxyudin / [WordPress] Redefine get_terms() default arguments
Created June 7, 2019 12:40
[WordPress] Redefine get_terms() default arguments
// https://wordpress.stackexchange.com/questions/339849/how-to-list-categories-in-reverse-alphabetical-order/339853#339853
add_filter( 'get_terms_args', 'mxd_term_args', 10, 2 );
function mxd_term_args( $args, $taxonomies ) {
// don't affect admin area
if ( is_admin() ) {
return $args;
}
@maxyudin
maxyudin / [WordPress] Add taxonomy editing messages
Created March 16, 2019 10:08
[WordPress] Add custom taxonomy term editing messages
/**
* See wp-admin/includes/edit-tag-messages.php
*/
add_filter( 'term_updated_messages', 'my_term_updated_messages' );
function my_term_updated_messages( $messages ) {
// $messages['MY_TAXONOMY']
$messages['movie_genre'] = array(
0 => '', // 0 = unused. Messages start at index 1.
1 => __( 'Movie Genre added.' ),
@maxyudin
maxyudin / [WordPress] Make post (page) list table custom column sortable
Created March 8, 2019 14:09
[WordPress] Make post (page) list table custom column sortable
<?php
// https://wordpress.stackexchange.com/a/293403/11761
// Make sure to change MY_POST_TYPE, MY_CUSTOM_COLUMN and MY_META_KEY to the actual values.
// Add your custom column. Unset the date and set it again to keep it in the last column. You can skip this step.
function my_manage_MY_POST_TYPE_columns( $columns )
{
// save date to the variable
@maxyudin
maxyudin / [WordPress] Sort WP_Query results by multiple meta keeping Top Picks
Last active March 7, 2019 12:06
[WordPress] Sort WP_Query results by multiple meta keeping Top Picks
<?php
/*
* Source: https://www.billerickson.net/wp-query-sort-by-meta/
*/
// Query Arguments
$args = array(
'post_type' => 'review',
'posts_per_page' => 10,
<?php
/*
* Based on https://wordpress.stackexchange.com/a/228071/11761
*
*/
$post_type = 'item';
$taxonomy = 'item_tags';
// count the number of terms for correct pagination
<?php
// Modified from https://gist.github.com/ericclemmons/6275346#gistcomment-2248160
// Add to: path/to/wp-content/wp-themes/your-theme/functions.php
/**
* Activate required plugins
*/
include_once ( ABSPATH . 'wp-admin/includes/plugin.php' );
foreach ( array('plugin-name',) as $plugin ) {
<?php
add_action( 'restrict_manage_posts', 'mxbd_filter_listings_by_smth' );
function mxbd_filter_listings_by_smth() {
if (isset($_GET['post_type']) && 'listing' == $_GET['post_type']) {
$selected_cat = isset($_GET['listing_cat']) ? $_GET['listing_cat'] : '';
wp_dropdown_categories(array(
function mxd_subpages($id)
{
// echo '<p>Parent: ' . wp_get_post_parent_id($id);
$children = get_pages( array(
'child_of' => $id,
'sort_order' => 'ASC',
'sort_column' => 'menu_order, post_title',
'hierarchical' => 0,