You can get theme’s main file using following:
$theme_info_file = trailingslashit( get_template_directory() ) . 'style.css';
To get the plugin’s main file you need to know the plugin name. And then you can use following function:
function get_plugin_file( $plugin_name ) {
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
$plugins = get_plugins();
foreach( $plugins as $plugin_file => $plugin_info ) {
if ( $plugin_info['Name'] == $plugin_name ) return $plugin_file;
}
return null;
}
For example to get the plugin main file for Akismet.
$akismet_plugin_file = trailingslashit( WP_PLUGIN_DIR ) . get_plugin_file( 'Akismet' );
Related Posts:
- framework for plugin/theme options panel? [closed]
- How to get the path to the current theme?
- Why does WordPress use outdated jQuery v1.12.4?
- Single functions.php or split into many small files?
- What is an alternative method to the WordPress private _doing_it_wrong() function
- What is the difference between esc_html and wp_filter_nohtml_kses?
- Check for featured image in WP_Query
- Update exisiting site to 3.5 release candidate
- Get file headers in custom file
- add_filter and remove_filter added before and after wp_query
- What is the difference between strip_tags and wp_filter_nohtml_kses?
- Having Problem On Getting WP Post Gallery Images URL
- What’s the difference between hooks, filters and actions? [duplicate]
- add_theme_support using a plugin
- How to bundle a plugin with a theme, or vice versa
- How Can I setup WP CLI on Windows development machine running AMPPS?
- WP_LOCALIZE_SCRIPT doesn’t work
- What is the difference between these two methods of writing $ instead of jQuery in WordPress [closed]
- Modify a Free Plugin available on wordpress.org & include with my Premium Theme? [closed]
- Paging on a future post loop?
- Best choice of options/settings framework for plugin/theme development
- Is there any way to have Featured Text, as opposed to Featured Image?
- Find source of notice / warning / errors efficiently
- Problem with is_active_sidebar?
- StackExchange clone using WordPress?
- Sharing common functionality (functions, template parts) between plugins and themes?
- Change template dynamically
- Display content from custom post without modifying the single template
- Can I change header.php of current theme through a plugin function?
- Get Current Menu Location inside Nav_Walker
- Tried in different ways but sidebar not working?
- Short code not working in boostrap modal dont no why?
- Is there a way to list all actions registered by a plugin or theme?
- Howto: Use Custom Post Types as Submenu Items in Admin
- How to hook a custom user function to a wordpress core ajax action?
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- WP Gutenberg Blocks – How to limit first/root blocks
- How developed with version control word press site on shared host? [closed]
- Following WordPress Markup Is mandatory, got awkward resultyby wordpress standard markup?
- How do I create plugin or theme using MVC pattern?
- How to limit number of number of categories displayed by categories widget
- PowerPress mobile media player
- When is the proper time to minify css and js with git workflow?
- How to Get Current Custom Post Type Associated Taxonomy Term
- Plugin templates vs Parent Theme
- Widget HTML Display Problem
- How to create a backend for a custom theme?
- wp_nonce_field displaying twice
- WP Plugin Running before jQuery
- How to only load css for used blocks on frontend
- my own SVN for a plugin/theme
- Why enqueue styles on hook?
- Getting a WordPress Debug Strategy
- PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory
- Invalid hook call on save, not edit when using swiper slider
- Proper way to use useSelect
- Conditional Generation of Image Sizes using add_image_size
- WP Still Generating 150×150 Thumbnail Size Even After Un-Setting Small Size in Functions.php
- modify show UI of a registered taxonomy
- Using function from enqueued .js file in theme in plugin?
- Does WordPress default CSS have Grids?
- Using HTML links within translatable string
- How to get terms for taxonomy
- How to remove/replace current page template?
- WordPress Page Reload Takes forever during theme development
- Adjust query on single
- Using password protection to load different page elements?
- Anyone using unzip_file successfully? It uploads the zip but doesn’t extract it!
- Pass custom props to
- How do I add filter with woocommerce categories?
- Can’t upload image via submitting custom post from frontend
- Need Help to make a logic for editing posts in Frontend
- How can we stop showing short code in create or edit post section
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- How can I measure CPU and RAM used by my theme or plugin
- set a custom post type to a taxonomy term programmatically in metabox
- redirect_to how to make it simply work with get parameter or similar?
- My enqueue admin style function doesn’t work because of ?=ver
- Determine if the current page, is being edited
- Can i prevent the effect of the_title filter on the dashboard’s posts/pages titles?
- How to embed or integrated a custom WordPress Widget into the theme?
- To remove rendering of menus and header, plugin or theme?
- WordPress permalink setting
- Custom theme and plugin updating
- How can I add recent posts to menu like mashable
- Is there a general way to get a themes primary colour?
- problem with blank page
- How to Register/Link to .js Files in WordPress Dynamicaly in Header.php
- If I want to create new taxonomies (e.g. Project / Documents / Etc…) is it better to create them in the theme’s functions.php or within a plugin? [duplicate]
- How to add something after a function
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- Loading jQuery library from WordPress admin
- Using tag or inline style attribute?
- how to insert content into wp_head after loop_end
- how many rupee or dollar charge to client to make theme [closed]
- How react js and other Javascript Technologies works on WordPress plugin?
- Is there any other ways to replicating changes on live from staging without pushing from git
- Fetch Custom Woocomerce filed data and check the data avialble in Wp-user table as nicname or username using function.php
- Remove Gutenberg Buttons Block
- User set default settings for a Block in Site Editor