Skip to content

Instantly share code, notes, and snippets.

@Surbma
Surbma / responsive.css
Last active Dec 21, 2017
Media queries for CSS
View responsive.css
// Mobile First
@media (min-width: 480px) {
}
@media (min-width: 768px) {
}
@media (min-width: 960px) {
}
@Surbma
Surbma / shortcodes.php
Last active Dec 17, 2017
WordPress shortcode examples
View shortcodes.php
<?php
function surbma_simple_shortcode() {
return '<div></div>';
}
add_shortcode( 'simple', 'surbma_simple_shortcode' );
function surbma_simple_shortcode_with_content( $content = null ) {
return '<div>'.do_shortcode( $content ).'</div>';
}
@Surbma
Surbma / surbma-enable-mime-types.php
Last active Dec 17, 2017
WordPress - Enable mime types
View surbma-enable-mime-types.php
<?php
function surbma_enable_mime_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'surbma_enable_mime_types' );
@Surbma
Surbma / surbma-wc-add-to-cart-button.php
Last active Jul 28, 2017
Add to cart button for product listings
View surbma-wc-add-to-cart-button.php
<?php
function surbma_wc_add_cart_button () {
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action( 'after_setup_theme', 'surbma_wc_add_cart_button' );
@Surbma
Surbma / surbma-custom-translations.php
Created Jun 7, 2017
Custom translations for WordPress
View surbma-custom-translations.php
<?php
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function surbma_custom_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Elfelejtetted a jelszavadat?' :
$translated_text = 'Elfelejtette a jelszavát?';
@Surbma
Surbma / surbma-clean-file-names.php
Last active Sep 14, 2017
WordPress - Clean filenames from special characters on upload
View surbma-clean-file-names.php
<?php
add_filter( 'sanitize_file_name', 'surbma_clean_file_names', 10 );
function surbma_clean_file_names ( $filename ) {
$tmp = explode( '.', $filename );
$ext = end( $tmp );
$file = substr( $filename, 0, -( strlen( $ext )+1 ) );
$file = str_replace(' ', '-', $file);
$file = str_replace('_', '-', $file);
$file = str_replace('.', '-', $file);
You can’t perform that action at this time.