Skip to content

Instantly share code, notes, and snippets.

@hnq90
hnq90 / functions.php
Created January 11, 2018 16:52 — forked from yoren/functions.php
Parent Post From Another Post Type And A New URL Structure In WordPress
<?php
// Flush rewrite rules after switch theme
function my_rewrite_flush() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_rewrite_flush' );
// A little help so we can get the stylesheet from parent theme
// Remove line 10-19 if this is not a child theme
function my_enqueue_styles() {
@erropix
erropix / oxy-cm-theme.scss
Created September 21, 2020 10:35
An Advanced Scripts snippet to enhance the Oxygen code editor theme
/*
Title: Oxygen Code Editor Theme
Type: CSS > Compile SCSS Code
Location: Custom Hooks
Hook name: oxygen_enqueue_ui_scripts
Priority: 10
*/
#oxygen-ui {
.cm-s-default {
@gyrus
gyrus / preload-images.js
Last active March 3, 2021 11:57
WordPress image preloading
/**
* Image preloader
*
* @link http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript
*/
var cache = [];
// Arguments are image paths relative to the current page.
function pilau_preload_images() {
var args_len, i, cache_image;
args_len = arguments.length;
@soderlind
soderlind / get-ip.php
Last active July 12, 2021 09:14
PHP, Get IP behind trusted proxy
<?php
/**
* Inspired by https://raw.githubusercontent.com/zendframework/zend-http/master/src/PhpEnvironment/RemoteAddress.php
*/
//PHP 5.6
function get_ip( $trusted_proxies = [] ) {
if ( ! empty( $trusted_proxies ) && isset( $_SERVER['REMOTE_ADDR'] ) && ! in_array( $_SERVER['REMOTE_ADDR'], $trusted_proxies ) ) {
if ( isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) {
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
} elseif ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
@amboutwe
amboutwe / yoast_seo_json_remove.php
Last active July 23, 2021 08:08
Remove all JSON output by Yoast SEO
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove all JSON output by Yoast SEO
* Credit: Yoast development team
* Documentation: https://developer.yoast.com/schema-documentation/api/
* Last Tested: Apr 16 2019 using Yoast SEO 11.0 on WordPress 5.1.1
*/
add_filter( 'wpseo_json_ld_output', '__return_false' );
@habibimroncn
habibimroncn / pll.md
Last active January 3, 2022 11:59
Get Current language on Polylang Plugin for Wordpress.

Reference for language code : Language Code

<?php 
$currLang = get_bloginfo('language');
if($currLang == "id-ID"){ // Replace condition with your language code.
	echo 'Bahasa Indonesia';
} else {
	echo 'up to you'
}
?&gt;
@wplit
wplit / style.css
Last active February 14, 2022 07:23
Allow tabbing across the sub menu items in Oxygen Menu (for keyboard user)
/* Allows focus on sub menu items by tabbing menu
------------------------------------------------ */
.oxy-nav-menu:not(.oxy-nav-menu-open) .menu-item .sub-menu {
right: 5000px;
visibility: visible;
}
.oxy-nav-menu:not(.oxy-nav-menu-open).menu-item .sub-menu .sub-menu {
right: auto;
@wplit
wplit / snippet.php
Created January 26, 2022 22:40
Remove 'global styles inline' from WP 5.9
add_action( 'wp_enqueue_scripts', 'lit_remove_global_inline_styles' );
function lit_remove_global_inline_styles() {
wp_dequeue_style('global-styles');
};
@isotrope
isotrope / example-menu-item.css
Last active March 22, 2022 06:42
Add (a) Polylang switcher menu item(s) to any menu.
/*
Example CSS of how I was showing one OR the other, based on brwoser-width
*/
@media (max-width: @grid-float-breakpoint-max) {
.language-code {
display: none;
}
}
@leoken
leoken / wp-bootstrap-footer-nav.php
Created October 13, 2012 06:01
For creating a footer nav in WordPress using the bootstrap scaffolding