esc_attr() right way and use

No you don’t need esc_attr() function to print out fixed static text. You only need it to print out dynamic or generated text, so that if the attributes have any special characters that may break your HTML, esc_attr will escape that properly. In your particular case, you can just write: echo ‘<label><input type=”checkbox” id=”custom_header” name=”custom_header” … Read more

Shared functionality in plugins and themes

Actions & Filters The imho best way is to use an action to bring plugin functions into themes. Example #1 Here’s a little plugin to test this. <?php /** Plugin Name: (#68117) Print Hello! */ function wpse68117_print_hello() { echo “Hello World!”; } add_action( ‘wpse68117_say’, ‘wpse68117_print_hello’ ); Inside the theme: <?php /** Template Name: Test »Print … Read more

Undefined offset: 0 in > […] /wp-includes/capabilities.php on line 1067

You have found a bug in Genesis. Your Xdebug stack trace fingers the culprit as the genesis_save_custom_fields() function which calls current_user_can() with a singular capability (edit_post and edit_page) which also requires an additional argument, in this case the post ID which is missing. current_user_can() calls has_cap() which calls map_meta_cap() which does a switch statement on … Read more

Display random categories on the front page (Finding and Editing Theme Functions)

The real question here is: How do I find “TheirCode” which is responsible for this selection using tools such as firefox dev bar and the actual source? If you are referring to the HTML output/source, then for example on the official Storefront theme demo site, just right-click on the “Product Categories” heading or section and … Read more

what the best way to include images from the template’s images folder?

The easiest and simplest way to do it is define a unique variable in your theme’s functions.php file. Such as: <?php $theme_name_images = get_bloginfo(‘stylesheet_directory’) . ‘/images/’; ?> No need for classes as a previous answer suggested. EDIT: It should be get_bloginfo, instead of bloginfo(), as Viper007Bond kindly pointed out.

How can I version the main CSS file?

Style.css is required for your WordPress theme. That’s where WordPress gets the theme name and meta information for the Appearance >> Themes menu from. That said, you don’t actually have to use style.css in your theme at all. I know of several readily available themes that don’t use it, and I only use it in … Read more

How can I create a bash install script for my WordPress sites setup (WP+plugins+theme)?

To always get latest plugin take for example my plugin: http://wordpress.org/extend/plugins/wordpress-file-monitor-plus/ the download link for the latest is: http://downloads.wordpress.org/plugin/wordpress-file-monitor-plus.1.1.zip but if you remove the version from the download link you always get the latest version: http://downloads.wordpress.org/plugin/wordpress-file-monitor-plus.zip EDIT: Have you considered keeping a folder of the latest wordpress and plugins unpacked? Then as soon as a … Read more

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