Tag Info

Hot answers tagged

7

There is plugin_basename() call some levels inside which seems to use WP_PLUGIN_DIR and WPMU_PLUGIN_DIR constants, so my guess would be this function is only meant to be used for things inside plugin directories and not other places like theme.


4

__DIR__ is rather new and not always supported. Use dirname( __FILE__ ). plugins_url() is using … $folder = dirname(plugin_basename($plugin)); … so yes, it is safe. Just use plugins_url( 'subfolder/file.css', dirname( __FILE__ ) )


3

Filter category_link so WordPress creates slashed URLs for categories, and redirect_canonical so it accepts those URLs: add_filter( 'category_link', 'wpse_71666_trailingslash_cat_url' ); add_filter( 'redirect_canonical', 'wpse_71666_trailingslash_cat_url', 20, 2 ); function wpse_71666_trailingslash_cat_url( $url, $request = '' ) { if ( 'category_link' ...


3

This is a PHP issue, not specific to WordPress. I suggest reading the PHP documentation on variable scope to understand why this doesn't work. There is no $plugin_url variable defined within the scope of your my_jquery_enqueue function, you would have to call global $plugin_url; first within the function to access it, though I don't suggest using something ...


3

The function you are looking for is called plugins_url() (ref), with the additional s. Should be fine afterwards.


3

function add_my_css_and_my_js_files(){ wp_enqueue_script('jquery-validate-min', plugins_url('activate/jquery_validate_min.js', __FILE__ ) ); } add_action('wp_enqueue_scripts', "add_my_css_and_my_js_files"); You need to use the plugins_url() function (you are missing the s at the end of plugins). Reference the location of the script file with the ...


2

Use plugin_dir_url() to get the public URI for the directory where the calling PHP file is. <img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/facebook.png'; ?>"> If the PHP file is in a sub directory of your plugin you have to go up: <img src="<?php echo plugin_dir_url( dirname( __FILE__ ) ) . 'images/facebook.png'; ?>">


2

Yes, any of those are possible and configurable under Settings > Permalinks. Have a look at the Permalinks page for other possibilities. One thing to note though, it's suggested to add a number at the beginning of your permalinks to reduce the number of rewrite rules WordPress has to generate to resolve all of your URLs. The permalink strings for your ...


2

There is plugin_dir_path(), but it's not exact analogue of plugins_url(). Also ABSPATH is unreliable for how you use it, related paths can be easily redefined. See default-constants.php file. Namely there are: WP_CONTENT_DIR WP_PLUGIN_DIR WPMU_PLUGIN_DIR


1

This is straightforward if I understand the question properly. Use the "WordPress MU Domain Mapping" plugin: http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/ Update I think something like the following should work in your .htaccess: RewriteCond %{HTTP_HOST} www.exampleurl.com RewriteCond %{REQUEST_URI} !^/testsite RewriteRule ^(.*)$ ...


1

Just use the domain mapping plugin. It odes what you want and yes it works on subfolder sites.


1

There aren't any for plugins, but you can (and should) use WP_CONTENT_DIR, instead of ABSPATH. For themes you have locate_template().


1

The plugins_url() function builds a URL string based on the Site URL you have configured. Remember, WordPress URL and Site URL are two different things. plugins_url() is merely a concatenation of: get_option( 'site_url' ) /wp-content The folder of the plugin So if you're seeing a www in your site, it's because site_url is set to use a www.


1

You can try to override it by using the following in config.php and see if it works as it will update your database, doing so will make it unable to be changed in your admin (it will be greyed out). define('WP_SITEURL', 'http://example.com/'); And some alternative definitions, http://codex.wordpress.org/Editing_wp-config.php#WordPress_address_.28URL.29 ...


1

Create a custom page template: <?php /** * Template Name: Random PHP */ get_header(); //add random PHP get_sidebar(); get_footer(); ?> Create a page in WordPress, give it the title portfolio. In the template select box choose Random PHP


1

Use if( file_exists(plugin_dir_path(__FILE__) . 'myfile.ext') ) {} instead of if( file_exists( plugins_url( "myfile.ext", __FILE__ ) ) ) {} See plugin_dir_path in the Codex.



Only top voted, non community-wiki answers of a minimum length are eligible