How To Load the Contact Form 7 Script for a Contact Page Only

Contact Form 7 loads its JavaScript and CSS files on every page and this cause load problems in the whole site specialy in the home page with PageSpeed Insights when i notice the CSS and JavaScript and there was no contact form there so what we need to fix this is to remove these js and css from any page who is not contact page that contains the contact form itself

all u need is to replace the word (contact-us) with the page name in your site

also this code need to be added to functions.php of your theme (or child theme) at the end of it

add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
function my_deregister_javascript() {
if ( !is_page('contact-us') ) {
wp_deregister_script( 'contact-form-7' );
}
}
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
if ( !is_page('contact-us') ) {
wp_deregister_style( 'contact-form-7' );
wp_deregister_style( 'contact-form-7-rtl' );
}
}

hope i saved you 2 or 3 sec in load time ๐Ÿ™‚

Good Luck

How To Setup Virtual Hosts (Real Domain) Using XAMPP

what i want to do is to use my new domain that i am developing on localhost but in the default wayย  http://localhost/website but using normal http://www.website.com

The Steps

You need to have XAMPP installed ( ๐Ÿ˜ )
Open up the Xampp control panel and stop Apache (Ensure that you donโ€™t have it running as a service โ€ฆ this is where doing so complicates things)
Navigate to C:/xampp/apache/conf/extra or wherever you installed xampp
Fire up your text editor with administrative privileges and open up httpd-vhosts.conf found in the C:/xampp/apache/conf/extra folder
At the very bottom of the file paste the following

<VirtualHost *:80>
 ServerAdmin localhost
 DocumentRoot "F:\xampp\htdocs"
 ServerName localhost
 ErrorLog "logs/dummy-host2.example.com-error.log"
 CustomLog "logs/dummy-host2.example.com-access.log" common
 </VirtualHost>

 

 

With out that line of code you will lose access to your default htdocs directory. IE. http://localhost/ will be inaccessible.

Now copy and paste the code below .. below the first code

 <VirtualHost *:80>
 ServerAdmin limor.com
 DocumentRoot "F:\xampp\htdocs\limor"
 ServerName limor.com
 ErrorLog "logs/dummy-host2.example.com-error.log"
 CustomLog "logs/dummy-host2.example.com-access.log" common
 </VirtualHost>

 

Now we head over to our Windows Hosts File, to edit the HOSTS. the file will be located at C:/Windows/System32/drivers/etc/hosts, where hosts is the file.

127.0.0.1 localhost

look for the line above, and enter your site mimicking the layout

127.0.0.1 localhost
127.0.0.1 http://www.limor.com

change it to reflect the lines above (if you have problems saving it meant you didnโ€™t have your text editor running in admin mode.

Restart Apache and test to make sure it is working

If you have any problems comment if not โ€ฆ give it a like

make anything works with qtranslate

add this

qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage

qTranslate tries to modify every String it can get its hand on, but unfortunately, custom Plugins often don’t supply filters nor use Gettext for their Strings, so it is impossible for qTranslate to filter out the correct language. You can fix it by yourself if you have some PHP knowledge, if not, you will need to ask the author of the other plugin to take a look at this page, as I don’t have the possibilty to modify their plugins.

There are 2 basic ways to make qTranslate work with your plugin:

  • Use Gettext to filter all output. WordPress already includes this function, so it can simply be added everywhere.
    //So if you have something like this
    do_someoutput("Code");
    // replace it with
    do_someoutput(__("Code"));
  • Use qTranslates internal translation filter. This function will be faster, but you will need to check wether the function exists or not (for non-qTranslate users).
    $filtered_string = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($raw_string);

Notice: __(‘””); will output meta information of the .mo file if called with an empty string! So you should make sure that it is only called with an non-empty string.

My suggestion would be using Gettext for texts that are non-dynamic (Title, Error Message). As for dynamic texts (comment text, blog entry text), I suggest using qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage() instead. Use something like this:

if(function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) $output = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($output);

qTranslate also modifys the WYSIWYG editor (TinyMCE) are creates a second instance with the corresponding text area (id=”qtranslate_textarea_content”). So if your plugin is inserting anything to tinyMCE, you will need to check if there is such a text area and if, insert to the qTranslate text area instead of the default text area.

If you are the author of a plugin and have trouble making your plugin work with qTranslate, feel free to contact me.

How to make qTranslate supports Custom Post Types?

How to make qTranslate supports Custom Post Types?

add this code in
wp-content/plugins/qtranslate/qtranslate_hooks.php

on line 303

add_filter('post_type_link','qtrans_convertURL');//fix custom post type URL

update:(20/06/2013)

Congrats to Qian Qin for writing some easily extensible code!

Here’s a relatively simple way of adding translations your own custom taxonomies.
Assuming you’ve registered a taxonomy, ‘my_cat’, add these two lines into qtranslate_hooks.php,
near the end of the file around line 244 (search for ‘// Hooks (Actions)’ in the file).

// Custom Taxonomies
add_action(‘my_cat_add_form’, ‘qtrans_modifyTermFormFor’);
add_action(‘my_cat_edit_form’, ‘qtrans_modifyTermFormFor’);

for example i am working on theme called increase it uses custom post type called Projects i looked in the functions and found the categories name is pj-sort-categs
so i added this line to the hooks

//increase projects
add_action(‘pj-sort-categs_add_form’, ‘qtrans_modifyTermFormFor’);
add_action(‘pj-sort-categs_edit_form’, ‘qtrans_modifyTermFormFor’);

and it showed me the languages to the custom post type Categories .