Skip to content

Instantly share code, notes, and snippets.

Avatar

Vladimír Smitka lynt-smitka

View GitHub Profile
View gist:252bbbd51006714ce0b3f4fe9892fd93
add_filter( 'wp_image_editors', 'lynt_wp_image_editors' );
function lynt_wp_image_editors( $editors ) {
//return array( 'WP_Image_Editor_GD' ); //only GD
//return array( 'WP_Image_Editor_Imagick' ); //only Imagick
}
View path.php
<?php
echo realpath(__FILE__);
@lynt-smitka
lynt-smitka / lynt-admin.php
Created Nov 18, 2020
WordPress - login as admin user
View lynt-admin.php
<?php
/**
* Plugin Name: Lynt Admin
* Author: Vladimir Smitka
* Author URI: https://lynt.cz/
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
defined( 'ABSPATH' ) or die( 'nothing here' );
View langredir.php
<?php
function prefered_language($available_languages, $http_accept_language) {
$available_languages = array_flip($available_languages);
$langs = array();
preg_match_all('~([\w-]+)(?:[^,\d]+([\d.]+))?~', strtolower($http_accept_language), $matches, PREG_SET_ORDER);
foreach($matches as $match) {
View remove-jquery-migrate.php
add_action('wp_default_scripts', 'lynt_remove_jquery_migrate');
function lynt_remove_jquery_migrate($scripts)
{
if (!is_admin() && isset($scripts->registered['jquery'])) {
$script = $scripts->registered['jquery'];
if ($script->deps) { // Check whether the script has any dependencies
$script->deps = array_diff($script->deps, array(
'jquery-migrate'
View js-async-loader.php
//doplní všem skriptům, na kterých nejsou jiné závislé atributy async a defer
if (!is_admin()) {
add_filter('script_loader_tag', 'lynt_async_attr', 10, 3);
}
function lynt_async_attr($tag, $handle, $src)
{
global $wp_scripts;
View my-custom-functions.php
<?php
/*
Plugin name: Moje funkce
*/
add_filter( 'get_the_archive_title', function ( $title ) {
if( is_category() ) {
$title = single_cat_title( '', false );
}
View hide-archive.php
add_filter( 'get_the_archive_title', function ( $title ) {
if( is_category() ) {
$title = single_cat_title( '', false );
}
if( is_tag() ) {
$title = single_tag_title( '', false );
}
View wp-simple-localization.php
<?php
function lynt_is_en() {
$path_parts = explode('/', $_SERVER['REQUEST_URI']);
if (isset($path_parts[1]) && $path_parts[1] === 'en') {
return true;
}
@lynt-smitka
lynt-smitka / ansible-info.yml
Created Feb 24, 2020
Run command on all ansible hosts and return output
View ansible-info.yml
- hosts: all
gather_facts: no
tasks:
- shell: uname -a
register: result
- debug: msg={{ result.stdout }}