Category Archive for "WordPress"

How to group Security Headers for web application using htaccess?

How to group group Security for web application using htaccess? Group Security Headers htaccess X-XSS-Protection sets the configuration for the cross-site scripting filters built into most browsers. The best configuration is “X-XSS-Protection: 1; mode=block”. X-Frame-Options tells the browser whether you want to allow your site to be framed or not. By preventing a browser from framing your site you can defend against attacks like clickjacking. X-Content-Type-Options stops a browser from trying to MIME-sniff the content type and forces it to stick with…

Read More

How to use WooCommerce’s default price at any custom template

To use WooCommerce’s price in your custom theme template open the template file and use the following code and see the magic. Example <?php global $post, $product; ?> <span itemprop=”price” class=”price”><?php echo $product->get_price_html(); ?></span> For default price template file of woocommerece you can look at folloiwng location yourtheme/woocommerce/loop/price.php. Open the file up and see the code used for the same <?php global $product; ?> <?php if ( $price_html = $product->get_price_html() ) : ?> <span class=”price”><?php echo $price_html; ?></span> <?php endif;…

Read More

How to use hooks (actions and filters) in wordpress and woocommerce

What are hooks? Hooks are helpful in WordPress which allow you to manipulate code without editing core files. It is used extensively used throughout WordPress and WooCommerce by developers. Two types of hook: actions and filters. Action Hooks allow you to insert custom code. Filter Hooks allow you to manipulate and return a variable. There are lot of excellent article on hooks and filters as follows: 1) https://codex.wordpress.org/Plugin_API 2) https://www.tipsandtricks-hq.com/wordpress-action-hooks-and-filter-hooks-an-introduction-4163 3) http://code.tutsplus.com/articles/the-beginners-guide-to-wordpress-actions-and-filters–wp-27373 4) http://blog.teamtreehouse.com/hooks-wordpress-actions-filters-examples Using hooks If you use a…

Read More

Steps To Follow When Updating WordPress

The WordPress upgrade system is improved itself from last version. However, there are some steps you can take care to ensure that your upgrades doesn’t affect anything. First and foremost, upgrades and updates should be done during your off hours i.e for off visit hours for your users. Usually this is at night, but it always depends on your site’s traffic. The key is to execute your update during a low activity time just in case something goes awry. Next,…

Read More

WordPress comment form validation

Copy and paste below and see the validation in working: <style type=”text/css”> .error { font-size: 12px; padding: 0 0 5px 0; color: #FF0000; } input.error, textarea.error { background: #FFD2D2; color:#000000; } </style> <?php function comment_validation_init() { if(is_single() && comments_open() ) { ?> <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js”></script> <script type=”text/javascript” src=”http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js”></script> <script type=”text/javascript”> jQuery(document).ready(function($) { $(‘#commentform’).validate({ rules: { author: { required: true, minlength: 2 }, email: { required: true, email: true }, comment: { required: true, minlength: 20 } }, messages: { author:…

Read More

WordPress comment form customization

Copy and Paste following into your functions.php file and see the customized form <?php function po_custom_comment_fields($fields) { //define global variable global $post; //remove defaults fields here $fields[‘url’] = ”; //begin custom fields $fields[‘firstname’] = ” . ‘<p class=”comment-form-firstname”><label for=”firstname”>’ . __( ‘First Name’ ) . ‘<span class=”required”>*</span></label>’ . ‘<input id=”firstname” name=”firstname” type=”text” value=”‘ . esc_attr( $commenter[‘firstname’] ) . ‘” size=”30″ aria-required=”true” /></p>’; $fields[‘lastname’] = ” . ‘<p class=”comment-form-lastname”><label for=”lastname”>’ . __( ‘Last Name’ ) . ‘</label>’ . ‘<input id=”lastname” name=”lastname”…

Read More

How to disable posts auto save in WordPress?

WordPress have a very useful function that auto-saves your posts while you’re typing them in the dashboard. Though, if for some reason you’d like to disable this function, it is very easy to do. Just read on! To disable WordPress autosaving function, simply open your functions.php file and paste the following function: function disableAutoSave(){ wp_deregister_script(‘autosave’); } add_action(‘wp_print_scripts’, ‘disableAutoSave’); That’s all. Once you saved the file, WordPress will never autosave a post. To enable autosaving again, simply delete this code. Shashi…

Read More

Briefly unavailable for scheduled maintenance

“Briefly unavailable for scheduled maintenance” message after doing automatic upgrade in WordPress? As part of the automatic upgrade WordPress places a file named .maintenance in the blog base folder (folder that contains the wp-admin folder). If that file exists, then visitors will see the message “Briefly unavailable for scheduled maintenance. Check back in a minute“. To stop that message from being displayed to visitors, just delete the .maintenance file. The automatic upgrade should be executed again, just in case it…

Read More

How to add custom post type in wordpress

Open “function.php” add the following code to add new custom post type : <?php add_action(‘init’, ‘featured_post_register’); function featured_post_register() { $labels = array( ‘name’ => _x(‘Featured Posts’, ‘post type general name’), ‘singular_name’ => _x(‘Featured Posts’, ‘post type singular name’), ‘add_new’ => _x(‘Add New’, ‘featured posts’), ‘add_new_item’ => __(‘Add New Featured Posts’), ‘edit_item’ => __(‘Edit Featured Posts’), ‘new_item’ => __(‘New Featured Posts’), ‘view_item’ => __(‘View Featured Posts’), ‘parent_item_colon’ => ” ); $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ =>…

Read More

Increasing the upload_max_filesize in WordPress Admin

The default upload file size for WordPress is 2 MB, which is a problem if you want to upload a large media files. If you get this error, “The uploaded file exceeds the upload_max_filesize directive in php.ini”, follow these steps: 1. Locate the php.ini file inside the wp-admin directory. 2. Find this line in the php.ini file “upload_max_filesize = 2M” and replace it with a higher value (e.g. “upload_max_filesize = 64M”) 3. You may also want to increase your max…

Read More