plugins_url() incorrectly returns a url with www subdomain

I’m working on a plugin which we’ll call “my-plugin” for the purposes of this question. The my-plugin directory looks like this: my-plugin/ |- image.jpg |- script.js |- script.php |- plugin.php |- ajax.php In script.php I have a section of code that specifies some JS. In it, I need a URL for ajax.php. e.g.: <script type=”text/javascript”> … Read more

Dropzone.js and wordpress plugin

I’m currently using Dropzone.js within a personal plugin and I’m able to create the dropzone, however when I pass in plugins_url as the action I’d like to get the files and add them to the wordpress media using the usual insert_attachment function found on the wordpress documentation. Dropzone: <form id=”udev-dropzone” method = “post” action=”<?php echo … Read more

plugin_dir_url() adds path to url

For some reason I get the following output from var_dump( plugin_dir_url( __FILE__ ) ); http://local.dev/wp-content/plugins/C:/development/xampp/htdocs/vanilla/wp-content/themes/twentyeleven/ in a local install. Note: I deactivated all plugins and added the line on top of the functions.php file of the default and unmodified TwentyEleven Theme 1 Answer 1 There is plugin_basename() call some levels inside which seems to use … Read more

Security in WordPress plugin development

My plugin is Mailer.app for WordPress, I’m 85% completed and I’m focusing on security before release. Before the questions, I should outline the plugins architecture: The plugin is able to take in username & password and relative imap/smtp server details. The details are validated and made sure that correct imap/smtp are entered (valid connection(s) made) … Read more

Is it safe to pass directory path to plugins_url()?

plugins_url() function accepts plugin slug or file path to build URL for. I have following directory structure: /wp-content/mu-plugins/someplugin/css/file.css /wp-content/mu-plugins/someplugin/includes/file.php I need to build URL to file.css in file.php. I can’t pass __FILE__ because that will be one level too deep. plugins_url(‘css/file.css’, __FILE__ ) I can pass __DIR__ to get correct level and it seems to … Read more

Add forward slash on categories url (serve one version of a url)

How can I a add forward slash on categories URLs and serve only that version of a category (meaning URLs not ending in forward-slash will redirect to URLs ending in forward slash). I manage to remove the category base using the “WP No Category Base” plugin but I need to add a forward slash on … Read more

Posts URL structure like site.com/category/the-post-title

I’m new with wordpress and I would like to understand better if it’s possible to create pages with an url based on the category and then the post title, so: something like http://mysite.com/category-name/the-post-title or http://mysite.com/category-name/12345 (the post id) or http://mysite.com/category-name/12345/the-post-title does exist some plug-in do this or should I consider other ways like url_rewrite to … Read more

How to call images from your plugins image folder?

I’ve done a lot of research and learned a lot about WP constants and function usage for getting image paths etc. but still my original problem persists. <img src=”https://wordpress.stackexchange.com/questions/60230/<?PHP echo WP_PLUGIN_DIR .”vertical-social-buttons/images/facebook.png’?>”> <img src=”https://wordpress.stackexchange.com/questions/60230/<?PHP echo WP_PLUGIN_DIR .”vertical-social-buttons/images/facebook.png’?>”> <img src=”<?PHP echo plugins_url(‘vertical-social-buttons/images/facebook.png’, __FILE__);?>”> All give me broken images. Am I missing something obvious? 1 1 Use … Read more