How to check active theme is parent or child wordpress

I am working on a plugin in plugin. I make template folder and in template folder and there are files of plugin that shows my post type data.

First Scenario

When user activate my plugin the template folder move to active theme folder. Its working perfectly.

Second Scenario

Now If there is parent and child theme. When the parent theme activate the template folder move to parent theme but when user activate child theme the template folder also move to child theme.

Now i want that if user activate parent theme then template folder move to parent theme but when user activate child theme then it should not be moved.

Like:

if(parent theme active) {
    //files moved
} else {
    // Do nothing
}

I search from google and found wp_get_theme(); function but it is not fit for my work.

So is there any hook or function that i can write it and it solve my problem.

Here is my move folder function:

$foo_theme_dir = get_template_directory();
$foo_plugin_dir = plugin_dir_path( __FILE__ );

copy($foo_plugin_dir.'template/archive-foo_plugin.php', $foo_theme_dir.'template/archive-foo_plugin.php');

2 Answers
2

I try this code and it solve my problem

if ( is_child_theme() === false ) {
    // files moved
} else {
    // do nothing
}

Thankx to @birgire

Leave a Comment