difference of each codes for wordpress

First, check how define works on PHP. It defines a named constant, /admin is just a folder, in this case, it’s a folder that you have creatied to save JS files that are admin-related, that folder is located on name_THEME_ASSETS_URI which you previously defined as well as: name_THEME_ASSETS_URI . ‘/js’, so /admin is a folder … Read more

ABSPATH in Windows

Windows does support both styles of slashes in path. I am not sure if ABSPATH definition is safe to edit: pro it’s in wp-config.php con it’s says to not edit following above it Myself I just use it as is, or replace slashes to make them uniform when putting path together. If that doesn’t work … Read more

Calling directories to load in wordpress

I usually split my theme’s functions into several files as well, and include those in my functions.php, like so: // load helper functions require_once get_stylesheet_directory().’/inc/helper-functions.php’; // load admin functions if (is_admin()) require_once get_stylesheet_directory().’/inc/admin-functions.php’; // load theme functions require_once get_stylesheet_directory().’/inc/theme-functions.php’; // load post functions require_once get_stylesheet_directory().’/inc/post-functions.php’; // load WooCommerce functions if (in_array(‘woocommerce/woocommerce.php’, apply_filters(‘active_plugins’, get_option(‘active_plugins’)))) require_once get_stylesheet_directory().’/inc/woocommerce-functions.php’; … Read more

Define a wordpress constant through plugin functions?

I don’t think you should define constants in your plugin. It will be very hard to debug later on. IMHO using wp_revisions_to_keep filter will be much nicer solution. So your code could look like this: add_filter( ‘wp_revisions_to_keep’, ‘my_revisions_to_keep_based_on_settings’, 10, 2 ); function my_revisions_to_keep_based_on_settings( $num, $post ) { // change that according to your needs return … Read more

Accessing site’s root from themes folder

I guess you’re talking about a site specific wp-config.php file that resides in your themes folder. At the point where you’re loading the wp-config.php file, WP isn’t fully loaded, so you ain’t got any constants or filesystem API or other basic API functions available. Here’s how I approach this: Structure # Dir structure ~/ROOT ├── … Read more

Use theme constants in plugin?

TEMPLATEPATH and STYLESHEETPATH will be deprecated in the near future. It is not safe to rely on these constants. Use get_template_directory() and get_stylesheet_directory() instead. And wait until the init hook (or after_setup_theme before you use them to be sure all needed files are loaded. Example for a plugin: add_action( ‘after_setup_theme’, ‘wpse_50359_set_plugin_basics’ ); function wpse_50359_set_plugin_basics() { … Read more