I want to move my files and images folder from plugin folder to theme folder. I move my files to another folder successfully and make a images folder also successfully, but when i move my images to theme “images” folder it does not work, i have no idea why it not work.

I also give permission to all files = 777

Here is my code:

//========= Move files from Plugin to Current Theme
$foo_theme_directory = get_option('foo_theme_directory');
if($foo_theme_directory == 'on'){
    $foo_theme_dir = get_template_directory()."/foo";
    define('FOO_THEME_DIR', $foo_theme_dir);
    if(file_exists(FOO_THEME_DIR)){
        $foo_plugin_dir = plugin_dir_path( __FILE__ );
        $foo_image_dir = get_template_directory()."/foo/images";
        define('FOO_IMAGE_DIR', $foo_image_dir);
        if(!file_exists(FOO_IMAGE_DIR)){
            mkdir(FOO_THEME_DIR.'/images', 0777, true);
        }
    // Move Images to images folder
        copy($foo_plugin_dir.'foo/images/foo_icon_arrow.png', $foo_images_dir.'/foo_icon_arrow.png');
        copy($foo_plugin_dir.'foo/images/foo_article_icon_img.png', 
$foo_images_dir.'/foo_article_icon_img.png');
        copy($foo_plugin_dir.'foo/images/foo_bg_reply.png', $foo_images_dir.'/foo_bg_reply.png');
        copy($foo_plugin_dir.'foo/images/foo_breadcrum_sep.png', $foo_images_dir.'/foo_breadcrum_sep.png');
        copy($foo_plugin_dir.'foo/images/foo_large.png', $foo_images_dir.'/foo_large.png');
        copy($foo_plugin_dir.'foo/images/foo_med.png', $foo_images_dir.'/foo_med.png');
        copy($foo_plugin_dir.'foo/images/foo_search_btn.png', $foo_images_dir.'/foo_search_btn.png');
    // Move files to foo folder
        copy($foo_plugin_dir.'foo/foo_artilces_list.php', FOO_THEME_DIR.'/foo_artilces_list.php');
        copy($foo_plugin_dir.'foo../foo_style.css', FOO_THEME_DIR.'../foo_style.css');
        copy($foo_plugin_dir.'foo/single-foo_articles.php', FOO_THEME_DIR.'/single-
foo_articles.php');
    }
    else{
        //echo "No";
    }
}

I don’t get the error why images not copy. Any idea

Read more here: Copying images from one folder to another folder in wordpress issue


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: