Translating wordpress plugin

You get the current language of the install with the function get_locale(). WordPress save the language in theoptions table, option_name is WPLANG. But inside the Multisite install is in the table sitemeta. But is not important. You should use the default functions to load a language file inside the theme template or the plugin. Theme: … Read more

WordPress plugin – multiple php files

In most cases you shouldn’t access your plugin’s PHP files directly. By itself file is just a file, it has no way of knowing it is part of WordPress installation. Even purposely loading WP core from arbitrary file is very challenging to do in a generic and reliable way. What you should be doing is … Read more

How to redirect from plugin page

Added hook to process all form values and than redirecting as per process result: Added below PHP code in theme/functions.php: function process_form(){ //code goes here } add_action( ‘admin_post_appointment_form_process’, ‘process_form’ ); And added/updated below html to form: <form name=”frm1″ id=”frm1″ action=”<?php echo home_url()?>/wp-admin/admin-post.php” method=”post”> <input type=”hidden” name=”action” value=”appointment_form_process”> Thanks for @Milo comment.

how to open image gallery in a post/page?

Whenever you create a gallery, in the gallery settings (right side of the Edit Gallery screen), you have the option Link to: Link to attachment page Link to media file Nothing Link to media file will open the image. Be advised that without some form of Lightbox plugin, the image will NOT open in an … Read more

Media Playlist Plugin

Here’s a quick example showing how you would pass php data to your script. First, we hook our function to the wp_enqueue_scripts action. Inside, we enqueue the script that contains the player and initialization code (this is probably two separate files, but I’ve condensed it to a single file in this example). Next, we call … Read more

WordPress Plugin Localization

The filter comes with the text domain as second argument. So you could do this: function wpdev_170138_plugin_locale( $locale, $domain ) { if ( $domain === ‘myplugin’ ) { return get_option( ‘jezik’ ); } return $locale; } add_filter( ‘plugin_locale’, ‘wpdev_170138_plugin_locale’, 10, 2 ); Now only your plugin’s locale is changed.

Multiple level shortcodes

Try passing the content of each shortcode through apply_filters( ‘the_content’, $content ); – you may not be getting your shortcode output because it’s never being called in the first place (beyond the top level). the_content filter include do_shortcode() (from memory), which is what you need. See how it goes…

Any way to edit/crop my featured image upon uploading?

This can be achieved by either creating an image size using <?php add_image_size( ‘my-image-size’, 1000, 400, true ); ?> or you can implement the Aqua Resizer to your theme/plugin. Aqua Resizer works almost in the same fashion as the good old TimThumb, but instead saves the image as a correct image size in WordPress using … Read more

Plugin’s required JS not being inserted in my theme

Hey by using enqueue script to add all js and css file wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); Example here /** * Proper way to enqueue scripts and styles */ function theme_name_scripts() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(), ‘1.0.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ ) i am sure … Read more