When you use the utility Partial on a type, it will make all the type properties optional. Let's see how we can compose this utility with another one, Omit, to make optional only certain properties of this type. We'll finally create a utility type using TypeScript generics to apply this on any type we want.… Continue reading TypeScript: make selected properties optional with Partial & Omit
Tag: tutorials
Prevent WordPress comment spam with a honeypot
Tweaking your user profile page in WordPress
The following functions will help you when tweaking your user page. Use them in the functions.php of your theme: <?php add_action( 'admin_head', 'user_profile_remove_color_scheme'); add_action( 'personal_options', 'sfn_personal_options'); add_action( 'show_user_profile', 'sfn_user_profile' ); add_action( 'edit_user_profile', 'sfn_user_profile' ); add_action( 'user_contactmethods', 'sfn_user_contactmethods'); //hooks for user registration and deletion add_action( 'user_register', 'sfn_user_register'); add_action( 'delete_user', 'sfn_delete_user'); function user_profile_remove_color_scheme() { global $_wp_admin_css_colors; $_wp_admin_css_colors… Continue reading Tweaking your user profile page in WordPress
Display sidebar widgets using a shortcode in WordPress
Widgets are one of the best WordPress tools: you can add a widgetized plugin and show its content in any sidebar in your site. But what happens if you want to show a widget within your post? In this tutorial we will learn how to create a sidebar to be displayed using a shortcode. Overview… Continue reading Display sidebar widgets using a shortcode in WordPress
Saving custom fields in quick or bulk edit mode in WordPress
One of the most cool features when managing WordPress posts, is the ability to batch edit multiple posts at once or even quick edit one post to perform a quick task such as adding a tag. In this WordPress tutorial, we will learn to extend Quick Edit and Bulk Edit to retrieve and save your custom field values.
How to add TinyMCE to textarea meta boxes in WordPress
Maybe one of the key factors in WordPress wild adoption, was the fact of the inclusion of TinyMCE, the rich text editor, for less tech-savvy users. Even ExpressionEngine, a paid CMS, doesn't include a rich text editor out-of-the-box. Moreover, you can add TinyMCE for your textareas in plugins or theme settings pages! In this tutorial… Continue reading How to add TinyMCE to textarea meta boxes in WordPress
CSS Card Flip using Webkit Transitions
Webkit brought a lot of enhancements to the formerly dull browser based user interfaces, with transform and transition properties being among the most useful for user interaction. In this tutorial we will learn how to use both to create a product card that flips to reveal more information with a fallback for browsers that don't… Continue reading CSS Card Flip using Webkit Transitions
How to detect iPhone browser natively in WordPress
WordPress has embraced the mobile revolution from the first moment. We have apps for iOS or Android and all the WordPress blogs can be accessed in iPad format. We also have in WordPress core a variable to detect if the user is visiting the site using an iPhone device. In this tutorial we will learn… Continue reading How to detect iPhone browser natively in WordPress
Avoid hierarchical taxonomies to loose hierarchy
You surely ran into this sometime: you've a hierarchical taxonomy in WordPress like Categories, you check the child terms and leave the parent terms unchecked. Next time you save the post, the hierarchical structure is broken and child items are positioned on top of parent items, like the image above on the left. In this… Continue reading Avoid hierarchical taxonomies to loose hierarchy
How to detect active widgets in each sidebar
While developing a WordPress theme for a sites network where the built-in calendar widget would be ocasionally included, a special background needed to be applied for the widgets area when the calendar was active, so I needed to detect if the calendar widget was active or not. In this tutorial we will learn how to… Continue reading How to detect active widgets in each sidebar