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

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

View WordPress page template usage (or unused)

What you need to do is compare the values of the meta field _wp_page_template, which contains the page template selected for a single page with the available page templates. For this you need to construct an array of used templates, because you want the templates used by all the pages, similar as shown here: Return … Read more

How do I white label my self-hosted site created by wordpress?

Here is the code I always use whenever I setup a new wordpress blog: CUSTOM ADMIN FOOTER TEXT // CUSTOMIZE ADMIN FOOTER TEXT function custom_admin_footer() { echo ‘<a href=”http://www.netconstructor.com/”>Website Design by NetConstructor, Inc.</a>’; } add_filter(‘admin_footer_text’, ‘custom_admin_footer’); REMOVE VERSION INFO FROM THE HEAD OF FEEDS // REMOVE VERSION INFO FROM THE HEAD OF FEEDS function complete_version_removal() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)