How to add favicon to my site – in both front end and admin panel

Update The following workaround is necessary for users who are using WordPress older than version 4.4. If you are using WordPress v4.4+ then you don’t need to go for such an extensive work-around. Simply follow the Usman Siddiqui’s answer, and it’s that easy. Actual Answer You can add a favicon into your WordPress site in … Read more

How to create a new theme from scratch?

An alternative to a “skinnable” theme framework like Carrington (which indeed is awesome) is to integrate a design you’ve done from scratch. This is how I learned how to create custom WordPress themes. Note: this is a hacky method that involves lots of experimentation. But if you’re like me, and learn best when you’re playing … Read more

WP 3.4 – what action/hook is called when theme customisation is saved?

The settings are saved via ajax, with the action customize_save. In the wp-includes/class-wp-customize-manager.php class, the callback for this ajax method is the save method (see source) This triggers the customize_save action, prior to updating each of the settings. Each setting is actually an instance of the class WP_Customize_Setting and saving the setting triggers the action … Read more

Best practices for a Style/CSS based theme options page?

creating a custom script that writes to the static CSS file is a bad idea!!! you would need to regenerate the file each time you save any changes. a better solution would be to save all options in an array of options say for example: $MyCSS[‘background_color’] = #009988; $MyCSS[‘background_repeat’] = no-repeat; update_option(‘theme_settings’,$MyCSS); and that why … Read more

How To Add New Option Types To Option Tree?

What you’re trying to do can be accomplished without ever editing the core files in OptionTree. Add your custom option type functions to your themes functions.php and the following code, as well. /** * Filter to add custom option types. * * @param array An array of option types. * @return array */ function add_custom_option_types( … Read more

When cropping a header image, retain meta data (i.e. name, description, etc.) from original image?

Here’s one idea, that might need further testing: /** * Cropped header image with the same description/caption as the original image */ add_filter( ‘wp_create_file_in_uploads’, function( $cropped, $attachment_id ) { add_filter( ‘wp_insert_attachment_data’, function( $data ) use ( $attachment_id) { if( doing_action( ‘wp_ajax_custom-header-crop’ ) && is_array( $data ) ) { // Copy the original description to the … Read more

Experiences with adding Nonces to the comment form

I haven’t done this personally, but it would be pretty easy. If you are building your comment form manually, just before the end of the </form> put: <?php wp_nonce_field( ‘comment_nonce’ ) ?> Then, just hook into the pre_comment_on_post action which fires when you submit a comment: add_action( ‘pre_comment_on_post’, ‘my_verify_comment_nonce’ ); function my_verify_comment_nonce() { check_admin_referer( ‘comment_nonce’ … Read more

Do Child-Themes automatically load the Translation from the Parent-Theme?

Is it enough to just create a child-theme – let’s say technically without adding anything else but the bare minimum style.css – to have the translation of the parent-theme being used automatically for the child-theme as well? Basically, the answer is NO, … but… there’s an option: Add a mu-plugin. This (MU-)Plugin does several things: … Read more