allow cross domain font access

custom CORS configurations to allow cross domain font access

This sets the Access-Control-Allow-Origin CORS configuration to allow pulling from all domains. You may also want to serve fonts to only specific domain, for that you have to replace ‘*’ with the domain names seperated with comma.

Customize Google Maps

Custom styles for google maps:
https://snazzymaps.com/about

Snazzy Maps is a community built around creating great looking styles for Google Maps.

As of version 3 of the Google Maps API custom styles can now be applied to maps. This allows developers and designers to pick a style that matches the theme of their website.

We love great resources that make web development easier and this is our way to give back to the community. Like any great resource it depends on great content. All styles on the site are created by our awesome users and shared free of charge.

All styles are licensed under creative commons and are completely free to use.

Snazzy Maps is an Atmist product and was created in Edmonton, Alberta, Canada. Feel free to contact us at support@snazzymaps.com or leave us some feedback on our UserVoice page.

programmatically add wpml string translation

First we need to register the string on wpml translation table.

The above function will return a string_id and we will need this id for icl_add_string_translation() function to add labels for other languages.

Alternatively, we can use icl_get_string_id() to get the string_id as:

Leverage browser caching

Enalbe mod_expires on server
LoadModule expires_module modules/mod_expires.so

And make following changes on htaccess file.
enable Cache-Control headers

enable Expires headers

You might also turn on the ‘KeepAlive’ connection. Read more on ‘keepalive’ https://abdussamad.com/archives/169-Apache-optimization:-KeepAlive-On-or-Off.html
Add the following code on htaccess to turn on ‘KeepAlive’, And you should know that Keepalive will improve website loading but will eat more ram.

present a pdf file for download via PHP after checking some rules

First we create a rule on htaccess and redirect the pdf files to a php with its path as query string

The sample code for the pdf-viewer.php.

Remove illegal characters from files during uploading on wordpress

wp_handle_upload_prefilter allows user to change the files during uploads.
http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_handle_upload_prefilter

ex.

What is the difference between inversedBy and mappedBy on Doctrine?

  • mappedBy has to be specified on the inversed side of a (bidirectional) association
  • inversedBy has to be specified on the owning side of a (bidirectional) association

from doctrine documentation:

  • ManyToOne is always the owning side of a bidirectional assocation.
  • OneToMany is always the inverse side of a bidirectional assocation.
  • The owning side of a OneToOne assocation is the entity with the table containing the foreign key.

doctrine documentation:
http://docs.doctrine-project.org/en/latest/reference/unitofwork-associations.html