Skip to content

Instantly share code, notes, and snippets.

@lusareal
lusareal / function.php
Created December 19, 2017 15:50 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
// Add to existing function.php file
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
@lusareal
lusareal / food-example-plugin-2.php
Created April 10, 2018 15:43 — forked from carlodaniele/food-example-plugin-2.php
An example for WPMU readers
<?php
/**
* @package Food_example_plugin_2
* @version 1.0
*/
/*
Plugin Name: Food example plugin 2
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin for WPMU DEV readers
Author: Carlo Daniele
@lusareal
lusareal / media-hacks.php
Created April 10, 2018 15:43 — forked from carlodaniele/media-hacks.php
An example WP plugin which adds functionalities to the WordPress Media Library
<?php
/**
* @package Media_hacks
* @version 1.0
*/
/*
Plugin Name: Media hacks
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
@lusareal
lusareal / custom-queries.php
Created April 10, 2018 15:43 — forked from carlodaniele/custom-queries.php
An example plugin showing how to add custom query vars, rewrite tags and rewrite rules to WordPress
<?php
/**
* @package Custom_queries
* @version 1.0
*/
/*
Plugin Name: Custom queries
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
@lusareal
lusareal / functions.php
Created April 10, 2018 15:49 — forked from tripflex/functions.php
WordPress Recursively get taxonomy hierarchy (courtesy of http://www.daggerhart.com/wordpress-get-taxonomy-hierarchy-including-children/ )
<?php
/**
* Recursively get taxonomy hierarchy
*
* @source http://www.daggerhart.com/wordpress-get-taxonomy-hierarchy-including-children/
* @param string $taxonomy
* @param int $parent - parent term id
*
* @return array
// умное позиционирование
var win = $(window);
var topOffset = selectbox.offset().top;
var bottomOffset = win.height() - selectHeight - (topOffset - win.scrollTop());
var visible = opt.selectVisibleOptions;
var minHeight = liHeight * 6;
var newHeight = liHeight * visible;
if (visible > 0 && visible < 6) minHeight = newHeight;
// раскрытие вверх
if (bottomOffset < 0 || bottomOffset < minHeight) {
<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2017.21.01
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */
@lusareal
lusareal / admin_filter_by_custom_fields.php
Created September 7, 2018 14:26 — forked from abrudtkuhl/admin_filter_by_custom_fields.php
WordPress Filter Posts By Custom Field Value In Admin
<?php
/*
Plugin Name: Admin Filter BY Custom Fields
Plugin URI: http://en.bainternet.info
Description: Filter posts or pages in admin by custom fields (post meta)
Version: 1.0
Author: Bainternet
Author URI: http://en.bainternet.info
*/
@lusareal
lusareal / PHP-get-timezone-from-address.php
Created February 1, 2019 15:51 — forked from mycarrysun/PHP-get-timezone-from-address.php
Gets the Timezone from an Address based on the current time
<?php
$addr = 'Columbus,OH,43235';
$maps_api_key = 'insert key here';
/**
* Gets the timezone id (eg. America/New_York, America/Detroit)
* @param string $address
* @return string|bool
*/
function get_timezone_from_address($address){
@lusareal
lusareal / wpml-detach-duplicates.sql
Created February 25, 2019 14:50 — forked from hampusn/wpml-detach-duplicates.sql
SQL queries to detach WPML duplicates and translate them separately.
# Select all posts which are duplicates of a language.
# The language parameter is to only select by the new language (not the original duplication language).
SET @lang_code = 'da';
SELECT pm.*, p.post_title, p.post_type, icl.language_code
FROM wp_postmeta pm
INNER JOIN wp_icl_translations icl ON icl.element_id = pm.post_id
INNER JOIN wp_posts p ON p.`ID` = pm.post_id
WHERE meta_key='_icl_lang_duplicate_of' AND icl.language_code = @lang_code;