Skip to content

Instantly share code, notes, and snippets.

View lynt-smitka's full-sized avatar

Vladimír Smitka lynt-smitka

View GitHub Profile
@lynt-smitka
lynt-smitka / prefer_gd.php
Created March 24, 2022 14:36
WordPress default image editor
add_action( 'wp_image_editors', function() {
return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
} );
RewriteCond %{QUERY_STRING} ^(.*?)(&?(?:fbclid|gclid|utm_source|utm_medium|utm_campaign|utm_term|utm_content)=[a-zA-Z0-9_-]+)(.*?)$
RewriteRule ^(.*)$ /$1?%1%3 [L,NE]
add_filter( 'document_title_parts', function( $title ) {
if ( is_home() || is_front_page() ) {
unset($title['tagline']);
}
return $title;
} );
add_filter( 'document_title_parts', function( $title ) {
unset( $title['site'] );
return $title;
} );
if ($query_string ~ "^(?<pre>.*?)(&?fbclid=[a-zA-Z0-9_-]+)(?<post>.*?)$"){
rewrite ^(.*)$ $1?$pre$post?;
}
if ($query_string ~ "^(?<pre>.*?)(&?utm_source=[a-zA-Z0-9_-]+)(?<post>.*?)$"){
rewrite ^(.*)$ $1?$pre$post?;
}
if ($query_string ~ "^(?<pre>.*?)(&?utm_medium=[a-zA-Z0-9_-]+)(?<post>.*?)$"){
rewrite ^(.*)$ $1?$pre$post?;
}
if ($query_string ~ "^(?<pre>.*?)(&?utm_campaign=[a-zA-Z0-9_-]+)(?<post>.*?)$"){
@lynt-smitka
lynt-smitka / function.php
Created June 30, 2021 17:43
Oxygen - shortcode render
function lynt_save_oxygen( $meta_id, $object_id, $meta_key, $meta_value ) {
if ( 'ct_builder_shortcodes' !== $meta_key ) return;
$post = get_post( $object_id );
if ( 'page' !== $post->post_type ) return;
$content = "<!-- wp:html -->\n" . do_shortcode( $meta_value ) . "\n<!-- /wp:html -->";
$postarr = [
'ID' => $post->ID,
'post_content' => $content
];
wp_update_post( $postarr );
@lynt-smitka
lynt-smitka / redirect-loop-contains.php
Last active May 3, 2021 10:08
Prevent redirect loop behind reverse proxy (wp-config.php)
if (
isset( $_SERVER['HTTP_X_FORWARDED_PROTO']) &&
strpos( $_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
$_SERVER['HTTPS']='on';
}
@lynt-smitka
lynt-smitka / wp-config-part-1-show.php
Last active April 21, 2021 08:33
Display/Log WordPress errors
define( 'WP_DEBUG', true );
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );
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
}
@lynt-smitka
lynt-smitka / 1-common.txt
Last active February 25, 2021 12:33
Dir buster lists
info.php
phpinfo.php
php_info.php
php-info.php
i.php
test.php
debug.php
admin.php
administrace.php
administration.php