[wp-trac] [WordPress Trac] #43992: Prevent activation of a plugin if its required PHP version is too high

WordPress Trac noreply at wordpress.org
Wed Feb 27 22:40:58 UTC 2019


#43992: Prevent activation of a plugin if its required PHP version is too high
-------------------------------------------------+-------------------------
 Reporter:  flixos90                             |       Owner:  (none)
     Type:  task (blessed)                       |      Status:  new
 Priority:  normal                               |   Milestone:  5.2
Component:  Plugins                              |     Version:
 Severity:  major                                |  Resolution:
 Keywords:  needs-unit-tests servehappy dev-     |     Focuses:
  feedback has-patch needs-testing               |
-------------------------------------------------+-------------------------

Comment (by DrewAPicture):

 Yeah, so @joyously's suggestion for using `get_file_data()` instead is a
 pretty elegant solution to the problem.  I didn't prepare a patch but a
 code example should suffice.

 '''Readme:'''
 {{{
 #!txt
 === Test Plugin ===
 Requires at least: 3.9
 Tested up to: 5.1
 Stable tag: 1.0.0
 License: GPLv2
 Requires WP: 5.0
 Requires PHP: 7.3
 }}}

 '''Read with:'''
 {{{
 #!php
 <?php
 $headers = array(
     'requires_at_least' => 'Requires at least',
     'tested_up_to'      => 'Tested up to',
     'stable_tag'        => 'Stable tag',
     'license'           => 'License',
     'requires_wp'       => 'Requires WP',
     'requires_php'      => 'Requires PHP',
 );

 var_dump( get_file_data( __DIR__ . '/readme.txt', $headers ) );
 }}}

 '''Outputs:'''
 {{{
 #!txt
 Array
 (
     [requires_at_least] => 3.9
     [tested_up_to] => 5.1
     [stable_tag] => 1.0.0
     [license] => GPLv2
     [requires_wp] => 5.0
     [requires_php] => 7.3
 )
 }}}

 I think `get_file_data()` should be more than adequate. And bonus points
 for leveraging something already in core!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43992#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list