• Resolved gcoulby

    (@gcoulby)


    I want to write a plugin, which executes code if the wordpress version or theme/parent theme version changes.

    I have this thus far.

    <?php
    class RunOnVersionChange {
    
        public static $wordpress_version = "3.9.1";
        public static $parent_theme_version = "6.5.6";
        public static $child_theme_version = "1.1";
    
        public static function check_versions(){
    
            if($wp_version > $this->wordpress_version){
                //execute code
                $this->wordpress_version = $wp_version;
            }
    
            $my_theme = $wp_get_theme();
            $my_theme_version = $my_theme->get( 'Version' );
    
            if($my_theme_version > $this->child_theme_version){
                //execute code
                $this->child_theme_version = $my_theme_version;
            }
        }
    }

    However, I need code that will also do the same process with the parent theme. I know I can echo the parent theme name, but in this instance that is useless to me. I need the version number. If there are any updates the version number will change and the code will execute to see if there are any conflicts. At the moment this is a very basic version. I also typed this direct into this text box so I apologise for any mistakes.

    Is this possible? If it’s not possible could the template name be used to find the directory of the template css and, then this file could be scanned for the version number manually. This is a very crude and slow approach…. and one which I would like to avoid if at all possible.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘echo parent theme's version’ is closed to new replies.