How to get path or root of plugin folder, not file or dir?

How about just define a constant that stores the plugin’s root path? Define path constant For calling numerous files, it is sometimes convenient to define a constant: define( ‘MY_PLUGIN_PATH’, plugin_dir_path( __FILE__ ) ); include( MY_PLUGIN_PATH . ‘includes/admin-page.php’); include( MY_PLUGIN_PATH . ‘includes/classes.php’); // etc. — See https://developer.wordpress.org/reference/functions/plugin_dir_path/#comment-491 So in your main plugin file: define( ‘MY_PLUGIN_PATH’, plugin_dir_path( … Read more

Hiding Directory Path

The easiest way to achieve this is to add, Options -Indexes ..to your .htaccess file. Specifically your .htaccess file should look like this, # BEGIN WordPress Options -Indexes …etc …etc # END WordPress This is one way and probably the most efficient way. This method will prevent any direct access outside of blog posts, pages, … Read more

Where is the right place to store custom images?

WordPress has a core function wp_upload_dir that return info for the current upload folder. Using this function you can retrieve all info on uploads folder base on current configuration. E.g. if you set WP_CONTENT_DIR and/or WP_CONTENT_URL or UPLOADS constants that function will return the direcory according to this settings. If you have checked the option … Read more

How can I stop access of unregistered user in wp-content/uploads directory without using .htaccess file?

WordPress is engineered not to interfere with existing files, including .htaccess rules it generates to enable use of pretty permalinks. Simply put you cannot make WP process or protect media files without some form of .htaccess or other web server configuration, because typically it handles them completely separately and WP doesn’t interfere with it.

WordPress root directory change + Theme directory change

You can move the installation and also plugin and content folder. The follow source demonstrate this. //* // Custom content directory define( ‘WP_CONTENT_DIR’, dirname( __FILE__ ) . ‘/wp-content’ ); define( ‘WP_CONTENT_URL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/wp-content’ ); // Custom plugin directory define( ‘WP_PLUGIN_DIR’, dirname( __FILE__ ) . ‘/wp-plugins’ ); define( ‘WP_PLUGIN_URL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . … Read more

wp_enqueue_script not loading my custom js file

You need to reference your WordPress template directory when you register the script. Change this: wp_enqueue_script(‘my_javascript_file’, ‘/javascripts/app.js’, array(‘jquery’)); …to this: wp_enqueue_script(‘my_javascript_file’, get_template_directory_uri() . ‘/javascripts/app.js’, array(‘jquery’)); Codex reference: get_template_directory_uri()

Function that outputs second theme url

You can use two inbuilt functions to do this. switch_to_blog get_stylesheet_directory_uri You can use both in the following way to make a function out of it which would give you the url to the theme. Put the below in the functions.php file function wpse_get_theme_url( $blog_id = 1 ){ switch_to_blog( $blog_id ); $template_url = get_stylesheet_directory_uri(); restore_current_blog(); … Read more

How to fix: “The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.”

Caveat I know this question is a little out of date and our question/issue is technically regarding an Azure WordPress Resource not a hosted environment… but I thought it might be helpful to answer for future readers. Background/Issue We spun up an Azure Worpress resource and migrated our site to it using updraft. Once transferred … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)