WordPress.org

Ready to get started?Download WordPress

Forums

WP version compare with beta snapshots (5 posts)

  1. Alphawolf
    Member
    Posted 6 years ago #

    Hey folks.

    I've just installed 2.6-beta1. In order to test plugin compatibilities, I used the version_compare php function. I'd like to insert some code in 2.6-beta1 but not in 2.5.1. I've tried this:

    if ( version_compare( $wp_version, '2.6', '>=' ) ) {
      // some code
    }

    but the code doesnt execute in 2.6-beta1. The version_compare did work a hundred times on other parts of the code.

    Don't I see the wood for the trees?

    edit. Since actually 2.6-beta1 is earlier than 2.6, I've also tried

    if ( version_compare( $wp_version, '2.5.9', '>=' ) ) {
      // some code
    }

    but that didnt work either.

    Regards.

  2. Lester Chan
    Member
    Posted 6 years ago #

    because $wp_version = '2.6-beta1'; I think it is the '-beta1' that is causing the problem.

  3. Alphawolf
    Member
    Posted 6 years ago #

    Considered the same. So, I cant pre-test "version-comparing" until 2.6 stable has been released?

  4. Lester Chan
    Member
    Posted 6 years ago #

    Disregard my previous comment

    if ( version_compare('2.6-beta1', '2.6-alpha1', '>=' ) ) {
    echo 'true 1';
    }
    if ( version_compare('2.6-beta1', '2.5.9', '>=' ) ) {
    echo 'true 2';
    }
    if ( version_compare('2.6-beta1', '2.6', '>=' ) ) {
    echo 'true 3';
    }

    Results: true 1true 2

    It does work for me.

  5. Alphawolf
    Member
    Posted 6 years ago #

    Whoops. Sorry, brain fart. $wp_version wasnt set and filled. :-)

Topic Closed

This topic has been closed to new replies.

About this Topic