Skip to content

Instantly share code, notes, and snippets.

View rotisoft's full-sized avatar

Tamas "RotiSoft" Rottenbacher rotisoft

View GitHub Profile
@rotisoft
rotisoft / gist:b713b635550dd74347c64c0783571ef8
Created October 23, 2017 09:14
Disable srcset for one thumbnail
add_filter( 'wp_calculate_image_srcset_meta', '__return_null' );
echo get_the_post_thumbnail( $page->ID, 'large' );
remove_filter( 'wp_calculate_image_srcset_meta', '__return_null' );
@rotisoft
rotisoft / gist:06002b0585f33fa45b4ab6a65d841d3b
Created October 23, 2017 11:15
WordPress srcset https redirect
function ssl_srcset( $sources ) {
foreach ( $sources as &$source ) {
$source['url'] = set_url_scheme( $source['url'], 'https' );
}
return $sources;
}
add_filter( 'wp_calculate_image_srcset', 'ssl_srcset' );
$send_time_rs = get_the_time('c');
$updated_time_rs = get_the_modified_time('c');
echo '<time class="published" style="display: none;" datetime="';
echo $send_time_rs;
echo '">';
echo $send_time_rs;
echo '</time> ';
if($send_time_rs!==$updated_time_rs) {
@rotisoft
rotisoft / woo_simple_or_variable.php
Last active January 16, 2018 13:22 — forked from trueqap/woo_simple_or_variable.php
WooCommerce simple or variable product
<?php
$product = new WC_Product( get_the_ID() ); // in function.php maybe...
if( $product->is_type( 'simple' ) ){
// a simple product
} elseif( $product->is_type( 'variable' ) ){
DELETE FROM wp_options WHERE option_name LIKE "%swift_performance%"
@rotisoft
rotisoft / gist:8a33fcb56a6faa78b9274b83a4949328
Created August 14, 2018 18:08
Woocommerce - Add sub categories list after description
add_action( 'woocommerce_archive_description', 'rs_woo_category_description' );
function rs_woo_category_description() {
$parentid = get_queried_object_id();
$args = array( 'parent' => $parentid);
$terms = get_terms( 'product_cat', $args );
if ( $terms ) {
echo '<hr>';
echo '<div class="rssubcategories">';
echo '<h2>Alkategóriák</h2>';
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
@rotisoft
rotisoft / wordpress-webp-upload.php
Last active March 30, 2021 22:26
WordPress WebP upload / feltoltes
/**
* Sets the extension and mime type for .webp files.
* @param array $wp_check_filetype_and_ext File data array containing 'ext', 'type', and * 'proper_filename' keys.
* @param string $file Full path to the file.
* @param string $filename The name of the file (may differ from $file due to
* $file being in a tmp directory).
* @param array $mimes Key is the file extension with value as the mime type.
*/
add_filter( 'wp_check_filetype_and_ext', 'wpse_file_and_ext_webp', 10, 4 );
/**
* Add that code to your WordPress site wp-config.php file.
* Replace the domain.tld to your site domain.
* Don't forget the https.
* Gist by Tamas Rottenbacher
* Source: https://wordpress.org/support/article/changing-the-site-url/
*/
define( 'WP_HOME', 'https://example.com' );
define( 'WP_SITEURL', 'https://example.com' );
@rotisoft
rotisoft / .htaccess
Last active August 28, 2021 10:09
WordPress honlaphoz ajánlott PHP értékek megadása, .htaccess fájl segítségével.
php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value max_execution_time 180
php_value max_input_time 300
php_value memory_limit 256M
php_value max_input_vars 10000