Skip to content

Instantly share code, notes, and snippets.

@Maksym-Marko
Maksym-Marko / nice-select.js
Last active October 5, 2023 09:23
vue.js 2 Nice Select. Using custom HTML markup instead of <select> tag.
/**
* Nice select component
* */
Vue.component('mx_nice_select', {
props: {
options: {
type: Array,
required: true
// [
// {
@Maksym-Marko
Maksym-Marko / xampp-local-domain.txt
Last active March 7, 2023 10:43
Setup XAMPP to access local domain directly
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost demo-domain-test.local
D:\xampp\apache\conf\httpd.conf
<VirtualHost demo-domain-test.local:80>
ServerName demo-domain-test.local
ServerAlias demo-domain-test.local
DocumentRoot "D:/xampp/htdocs/demo-domain-test.local/"
<Directory "D:/xampp/htdocs/demo-domain-test.local/">
Order allow,deny
@Maksym-Marko
Maksym-Marko / securityInterstitialCommandId.txt
Created December 2, 2022 06:49
Website doesn't open in Chrome
sendCommand(SecurityInterstitialCommandId.CMD_PROCEED)
@Maksym-Marko
Maksym-Marko / r-cpt.php
Last active March 5, 2021 08:02
Remove slug from CPT permalink
<?php
// create CPT
register_post_type( 'appeal', array(
'labels' => array(
'name' => 'Обращения',
'singular_name' => 'Обращение',
'add_new' => 'Добавить обращение',
'add_new_item' => 'Добавить обращение',
@Maksym-Marko
Maksym-Marko / get_results.php
Created January 14, 2021 13:57
$wpdb->get_results. Table relationships.
<?php
$posts_table = $wpdb->prefix . 'posts';
$term_relationships_table = $wpdb->prefix . 'term_relationships';
$sql_str = "SELECT ID, post_title, post_date, post_title, post_content
FROM $posts_table
INNER JOIN $term_relationships_table ON $posts_table.ID = $term_relationships_table.object_id
WHERE $term_relationships_table.term_taxonomy_id = $tax_id
@Maksym-Marko
Maksym-Marko / wp-menu.php
Last active January 14, 2021 07:43
WordPress menu items customize
<?php
// add class to <li>
add_filter( 'nav_menu_css_class', 'mx_add_class_to_menu_li_main_menu', 10, 4 );
function mx_add_class_to_menu_li_main_menu( $classes, $item, $args, $depth ) {
if( isset( $args->menu_id ) ) {
if ( 'primary-menu' == $args->menu_id ) {
@Maksym-Marko
Maksym-Marko / wp-menu-backend-customization.php
Created December 16, 2020 10:29
WordPress Menu Backend Customization
<?php
function mx_custom_fields( $item_id, $item ) {
wp_nonce_field( 'mx_menu_icon_nonce', '_mx_menu_icon_nonce_name' );
$mx_menu_icon = get_post_meta( $item_id, '_mx_menu_icon', true );
?>
<div class="field-mx_menu_icon description-wide" style="margin: 5px 0;">
<span class="description"><?php _e( "Font awesome ison", 'custom-menu-meta' ); ?></span>
@Maksym-Marko
Maksym-Marko / menu-walkers.php
Last active January 14, 2021 07:45
WordPress menu. Walker.
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
// About Us page
class MX_About_Us_Page_Walker_Nav_Menu extends Walker_Nav_Menu
{
public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
@Maksym-Marko
Maksym-Marko / mousewheel.js
Created November 17, 2020 16:04
JavaScript Mouse wheel event.
function detectMouseWheelDirection( e )
{
var delta = null,
direction = false
;
if ( !e ) { // if the event is not provided, we get it from the window object
e = window.event;
}
if ( e.wheelDelta ) { // will work in most cases
delta = e.wheelDelta / 60;
@Maksym-Marko
Maksym-Marko / common-options.php
Last active February 10, 2021 10:56
Option's page. Create common options for a website.
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
// add common content page
add_action( 'admin_menu', 'mx_common_content_page' );
function mx_common_content_page() {