WordPress.org

Plugin Directory

Changeset 1604837


Ignore:
Timestamp:
02/27/17 21:42:04 (4 weeks ago)
Author:
coffee2code
Message:

Release v2.2.4:

  • Fix: Fix a few unit tests
  • Change: Update unit test bootstrap
    • Default WP_TESTS_DIR to /tmp/wordpress-tests-lib rather than erroring out if not defined via environment variable
    • Enable more error output for unit tests
  • Change: Note compatibility through WP 4.7+
  • Change: Minor readme.txt content and formatting tweaks
  • Change: Update copyright date (2017)
  • New: Add LICENSE file
Location:
if-file-exists
Files:
2 added
5 edited
8 copied

Legend:

Unmodified
Added
Removed
  • if-file-exists/tags/2.2.4/if-file-exists.php

    r1395893 r1604837  
    22/** 
    33 * Plugin Name: If File Exists 
    4  * Version:     2.2.3 
     4 * Version:     2.2.4 
    55 * Plugin URI:  http://coffee2code.com/wp-plugins/if-file-exists/ 
    66 * Author:      Scott Reilly 
     
    1111 * Description: Check if a file exists and return true/false or display a string containing information about the file. 
    1212 * 
    13  * Compatible with WordPress 2.7 through 4.5+. 
     13 * Compatible with WordPress 2.7 through 4.7+. 
    1414 * 
    1515 * =>> Read the accompanying readme.txt file for instructions and documentation. 
     
    1919 * @package If_File_Exists 
    2020 * @author  Scott Reilly 
    21  * @version 2.2.3 
     21 * @version 2.2.4 
    2222 */ 
    2323 
    2424/* 
    25     Copyright (c) 2007-2016 by Scott Reilly (aka coffee2code) 
     25    Copyright (c) 2007-2017 by Scott Reilly (aka coffee2code) 
    2626 
    2727    This program is free software; you can redistribute it and/or 
  • if-file-exists/tags/2.2.4/readme.txt

    r1395893 r1604837  
    66License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    77Requires at least: 2.7 
    8 Tested up to: 4.5 
    9 Stable tag: 2.2.3 
     8Tested up to: 4.7 
     9Stable tag: 2.2.4 
    1010 
    1111Check if a file exists and return true/false or display a string containing information about the file. 
     
    1414== Description == 
    1515 
    16 This plugin provides the function `c2c_if_file_exists()` (and a couple others) that check if a file exists and either returns true/false or displays a string containing information about the file. 
    17  
    18 If a format string is not passed to it, the functions return a simple boolean (true or false) indicating if the specified file exists. 
    19  
    20 Otherwise, the format string provided to it will be used to construct a response string, which can be customized to display information about the file (such as file_name, file_url, or file_path). If the `$echo` argument is true, that string is displayed on the page. Regardless of the value of `$echo`, the response string is returned by the function. 
     16This plugin provides the functions `c2c_if_file_exists()`, `c2c_if_theme_file_exists()`, `c2c_if_plugin_file_exists()` that check if a file exists and either return true/false or display a string containing information about the file. 
     17 
     18* If a format string is not passed to it, the functions return a simple boolean (true or false) indicating if the specified file exists. 
     19* Otherwise, the format string provided to it will be used to construct a response string, which can be customized to display information about the file (such as file_name, file_url, or file_path). If the `$echo` argument is true, that string is displayed on the page. Regardless of the value of `$echo`, the response string is returned by the function. 
    2120 
    2221By default, 'c2c_if_file_exists()' assumes you are looking for the file relative to the default WordPress upload directory. If you wish to search another directory, specify it as the $dir argument. 'c2c_if_theme_file_exists()' assumes you are looking for a file relative to the currently active theme's home directory. 'c2c_if_plugin_file_exists()' assumes you are looking for a file relative to the directory that contains WordPress plugins. 
     
    2726== Installation == 
    2827 
    29 1. Unzip `if-file-exists.zip` inside the `/wp-content/plugins/` directory (or install via the built-in WordPress plugin installer) 
    30 1. Activate the plugin through the 'Plugins' admin menu in WordPress 
    31 1. In one or more of your templates, utilize one of the template tags provided by this plugin (see examples) 
     281. Install via the built-in WordPress plugin installer. Or download and unzip `if-file-exists.zip` inside the plugins directory for your site (typically `wp-content/plugins/`) 
     292. Activate the plugin through the 'Plugins' admin menu in WordPress 
     303. In one or more of your templates, utilize one of the template tags provided by this plugin (see examples) 
    3231 
    3332 
     
    9695== Filters == 
    9796 
    98 The plugin exposes three filters for hooking. Typically, customizations utilizing these hooks would be put into your active theme's functions.php file, or used by another plugin. 
     97The plugin exposes three filters for hooking. Code using these filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain). Less ideally, you could put them in your active theme's functions.php file. 
    9998 
    10099= c2c_if_file_exists (filter) = 
     
    154153 
    155154== Changelog == 
     155 
     156= 2.2.4 (2017-02-16) = 
     157* Fix: Fix a few unit tests 
     158* Change: Update unit test bootstrap 
     159    * Default `WP_TESTS_DIR` to `/tmp/wordpress-tests-lib` rather than erroring out if not defined via environment variable 
     160    * Enable more error output for unit tests 
     161* Change: Note compatibility through WP 4.7+ 
     162* Change: Minor readme.txt content and formatting tweaks 
     163* Change: Update copyright date (2017) 
     164* New: Add LICENSE file 
    156165 
    157166= 2.2.3 (2016-01-18) = 
     
    258267== Upgrade Notice == 
    259268 
     269= 2.2.4 = 
     270Trivial update: fixed some unit tests, noted compatibility through WP 4.7+, updated copyright date 
     271 
    260272= 2.2.3 = 
    261273Trivial update: improved support for localization, minor unit test tweaks, verified compatibility through WP 4.4+, and updated copyright date (2016) 
  • if-file-exists/tags/2.2.4/tests/bootstrap.php

    r829848 r1604837  
    11<?php 
     2/** 
     3 * PHPUnit bootstrap file 
     4 * 
     5 * @package If_File_Exists 
     6 */ 
    27 
    3 require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php'; 
     8ini_set('display_errors','on'); 
     9error_reporting(E_ALL); 
    410 
     11$_tests_dir = getenv( 'WP_TESTS_DIR' ); 
     12if ( ! $_tests_dir ) { 
     13        $_tests_dir = '/tmp/wordpress-tests-lib'; 
     14} 
     15 
     16// Give access to tests_add_filter() function. 
     17require_once $_tests_dir . '/includes/functions.php'; 
     18 
     19/** 
     20 * Manually load the plugin being tested. 
     21 */ 
    522function _manually_load_plugin() { 
    6     require dirname( __FILE__ ) . '/../if-file-exists.php'; 
     23        require dirname( dirname( __FILE__ ) ) . '/if-file-exists.php'; 
    724} 
    825tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); 
    926 
    10 require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php'; 
     27// Start up the WP testing environment. 
     28require $_tests_dir . '/includes/bootstrap.php'; 
  • if-file-exists/tags/2.2.4/tests/test-if-file-exists.php

    r1331893 r1604837  
    2929 
    3030 
    31     public function test() { 
     31    public function test_hooks_action_plugins_loaded() { 
    3232        $this->assertEquals( 10, has_action( 'plugins_loaded', 'c2c_if_file_exists_load_textdomain' ) ); 
    3333    } 
     
    106106 
    107107    public function test_show_if_not_exists_for_nonexistent_file() { 
     108        $dir = 'wp-includes'; 
    108109        $msg = 'file does not exist'; 
    109110 
     
    146147    public function test_if_plugin_file_exists_with_nonexistent_file() { 
    147148        $this->assertFalse( c2c_if_plugin_file_exists( 'nonexistent.txt' ) ); 
     149        $this->assertFalse( c2c_if_theme_file_exists( 'nonexistent.txt', '', false, 'text' ) ); 
    148150    } 
    149151 
     
    154156    public function test_if_theme_file_exists_with_nonexistent_file() { 
    155157        $this->assertFalse( c2c_if_theme_file_exists( 'nonexistent.txt' ) ); 
     158        $this->assertFalse( c2c_if_theme_file_exists( 'nonexistent.css', '', false, 'css' ) ); 
    156159    } 
    157160 
    158161    public function test_if_theme_file_exists_with_existing_file() { 
    159162        $this->assertTrue( c2c_if_theme_file_exists( 'style.css' ) ); 
    160         // TODO: Be smarter about this and find an actual file in a theme subdirectory. 
    161         $this->assertTrue( c2c_if_theme_file_exists( 'ie.css', '', false, 'css' ) ); 
     163        // TODO: Test finding a file in a subdirectory relative to current theme. 
     164        // (WP unit tests have no such example file to use.) 
     165        //$this->assertTrue( c2c_if_theme_file_exists( 'ie.css', '', false, 'css' ) ); 
    162166    } 
    163167 
     
    174178    public function test_filter_invocation_of_if_theme_file_exists() { 
    175179        $this->assertFalse( apply_filters( 'c2c_if_theme_file_exists', 'nonexistent.txt' ) ); 
    176         // TODO: Be smarter about this and find an actual file in a theme subdirectory. 
    177         $this->assertEquals( 'ie.css', apply_filters( 'c2c_if_theme_file_exists', 'ie.css', '%file_name%', false, 'css' ) ); 
     180        // TODO: Test finding a file in a subdirectory relative to current theme. 
     181        // (WP unit tests have no such example file to use.) 
     182        //$this->assertEquals( 'ie.css', apply_filters( 'c2c_if_theme_file_exists', 'ie.css', '%file_name%', false, 'css' ) ); 
    178183    } 
    179184 
  • if-file-exists/trunk/if-file-exists.php

    r1395893 r1604837  
    22/** 
    33 * Plugin Name: If File Exists 
    4  * Version:     2.2.3 
     4 * Version:     2.2.4 
    55 * Plugin URI:  http://coffee2code.com/wp-plugins/if-file-exists/ 
    66 * Author:      Scott Reilly 
     
    1111 * Description: Check if a file exists and return true/false or display a string containing information about the file. 
    1212 * 
    13  * Compatible with WordPress 2.7 through 4.5+. 
     13 * Compatible with WordPress 2.7 through 4.7+. 
    1414 * 
    1515 * =>> Read the accompanying readme.txt file for instructions and documentation. 
     
    1919 * @package If_File_Exists 
    2020 * @author  Scott Reilly 
    21  * @version 2.2.3 
     21 * @version 2.2.4 
    2222 */ 
    2323 
    2424/* 
    25     Copyright (c) 2007-2016 by Scott Reilly (aka coffee2code) 
     25    Copyright (c) 2007-2017 by Scott Reilly (aka coffee2code) 
    2626 
    2727    This program is free software; you can redistribute it and/or 
  • if-file-exists/trunk/readme.txt

    r1395893 r1604837  
    66License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    77Requires at least: 2.7 
    8 Tested up to: 4.5 
    9 Stable tag: 2.2.3 
     8Tested up to: 4.7 
     9Stable tag: 2.2.4 
    1010 
    1111Check if a file exists and return true/false or display a string containing information about the file. 
     
    1414== Description == 
    1515 
    16 This plugin provides the function `c2c_if_file_exists()` (and a couple others) that check if a file exists and either returns true/false or displays a string containing information about the file. 
    17  
    18 If a format string is not passed to it, the functions return a simple boolean (true or false) indicating if the specified file exists. 
    19  
    20 Otherwise, the format string provided to it will be used to construct a response string, which can be customized to display information about the file (such as file_name, file_url, or file_path). If the `$echo` argument is true, that string is displayed on the page. Regardless of the value of `$echo`, the response string is returned by the function. 
     16This plugin provides the functions `c2c_if_file_exists()`, `c2c_if_theme_file_exists()`, `c2c_if_plugin_file_exists()` that check if a file exists and either return true/false or display a string containing information about the file. 
     17 
     18* If a format string is not passed to it, the functions return a simple boolean (true or false) indicating if the specified file exists. 
     19* Otherwise, the format string provided to it will be used to construct a response string, which can be customized to display information about the file (such as file_name, file_url, or file_path). If the `$echo` argument is true, that string is displayed on the page. Regardless of the value of `$echo`, the response string is returned by the function. 
    2120 
    2221By default, 'c2c_if_file_exists()' assumes you are looking for the file relative to the default WordPress upload directory. If you wish to search another directory, specify it as the $dir argument. 'c2c_if_theme_file_exists()' assumes you are looking for a file relative to the currently active theme's home directory. 'c2c_if_plugin_file_exists()' assumes you are looking for a file relative to the directory that contains WordPress plugins. 
     
    2726== Installation == 
    2827 
    29 1. Unzip `if-file-exists.zip` inside the `/wp-content/plugins/` directory (or install via the built-in WordPress plugin installer) 
    30 1. Activate the plugin through the 'Plugins' admin menu in WordPress 
    31 1. In one or more of your templates, utilize one of the template tags provided by this plugin (see examples) 
     281. Install via the built-in WordPress plugin installer. Or download and unzip `if-file-exists.zip` inside the plugins directory for your site (typically `wp-content/plugins/`) 
     292. Activate the plugin through the 'Plugins' admin menu in WordPress 
     303. In one or more of your templates, utilize one of the template tags provided by this plugin (see examples) 
    3231 
    3332 
     
    9695== Filters == 
    9796 
    98 The plugin exposes three filters for hooking. Typically, customizations utilizing these hooks would be put into your active theme's functions.php file, or used by another plugin. 
     97The plugin exposes three filters for hooking. Code using these filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain). Less ideally, you could put them in your active theme's functions.php file. 
    9998 
    10099= c2c_if_file_exists (filter) = 
     
    154153 
    155154== Changelog == 
     155 
     156= 2.2.4 (2017-02-16) = 
     157* Fix: Fix a few unit tests 
     158* Change: Update unit test bootstrap 
     159    * Default `WP_TESTS_DIR` to `/tmp/wordpress-tests-lib` rather than erroring out if not defined via environment variable 
     160    * Enable more error output for unit tests 
     161* Change: Note compatibility through WP 4.7+ 
     162* Change: Minor readme.txt content and formatting tweaks 
     163* Change: Update copyright date (2017) 
     164* New: Add LICENSE file 
    156165 
    157166= 2.2.3 (2016-01-18) = 
     
    258267== Upgrade Notice == 
    259268 
     269= 2.2.4 = 
     270Trivial update: fixed some unit tests, noted compatibility through WP 4.7+, updated copyright date 
     271 
    260272= 2.2.3 = 
    261273Trivial update: improved support for localization, minor unit test tweaks, verified compatibility through WP 4.4+, and updated copyright date (2016) 
  • if-file-exists/trunk/tests/bootstrap.php

    r829848 r1604837  
    11<?php 
     2/** 
     3 * PHPUnit bootstrap file 
     4 * 
     5 * @package If_File_Exists 
     6 */ 
    27 
    3 require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php'; 
     8ini_set('display_errors','on'); 
     9error_reporting(E_ALL); 
    410 
     11$_tests_dir = getenv( 'WP_TESTS_DIR' ); 
     12if ( ! $_tests_dir ) { 
     13        $_tests_dir = '/tmp/wordpress-tests-lib'; 
     14} 
     15 
     16// Give access to tests_add_filter() function. 
     17require_once $_tests_dir . '/includes/functions.php'; 
     18 
     19/** 
     20 * Manually load the plugin being tested. 
     21 */ 
    522function _manually_load_plugin() { 
    6     require dirname( __FILE__ ) . '/../if-file-exists.php'; 
     23        require dirname( dirname( __FILE__ ) ) . '/if-file-exists.php'; 
    724} 
    825tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); 
    926 
    10 require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php'; 
     27// Start up the WP testing environment. 
     28require $_tests_dir . '/includes/bootstrap.php'; 
  • if-file-exists/trunk/tests/test-if-file-exists.php

    r1331893 r1604837  
    2929 
    3030 
    31     public function test() { 
     31    public function test_hooks_action_plugins_loaded() { 
    3232        $this->assertEquals( 10, has_action( 'plugins_loaded', 'c2c_if_file_exists_load_textdomain' ) ); 
    3333    } 
     
    106106 
    107107    public function test_show_if_not_exists_for_nonexistent_file() { 
     108        $dir = 'wp-includes'; 
    108109        $msg = 'file does not exist'; 
    109110 
     
    146147    public function test_if_plugin_file_exists_with_nonexistent_file() { 
    147148        $this->assertFalse( c2c_if_plugin_file_exists( 'nonexistent.txt' ) ); 
     149        $this->assertFalse( c2c_if_theme_file_exists( 'nonexistent.txt', '', false, 'text' ) ); 
    148150    } 
    149151 
     
    154156    public function test_if_theme_file_exists_with_nonexistent_file() { 
    155157        $this->assertFalse( c2c_if_theme_file_exists( 'nonexistent.txt' ) ); 
     158        $this->assertFalse( c2c_if_theme_file_exists( 'nonexistent.css', '', false, 'css' ) ); 
    156159    } 
    157160 
    158161    public function test_if_theme_file_exists_with_existing_file() { 
    159162        $this->assertTrue( c2c_if_theme_file_exists( 'style.css' ) ); 
    160         // TODO: Be smarter about this and find an actual file in a theme subdirectory. 
    161         $this->assertTrue( c2c_if_theme_file_exists( 'ie.css', '', false, 'css' ) ); 
     163        // TODO: Test finding a file in a subdirectory relative to current theme. 
     164        // (WP unit tests have no such example file to use.) 
     165        //$this->assertTrue( c2c_if_theme_file_exists( 'ie.css', '', false, 'css' ) ); 
    162166    } 
    163167 
     
    174178    public function test_filter_invocation_of_if_theme_file_exists() { 
    175179        $this->assertFalse( apply_filters( 'c2c_if_theme_file_exists', 'nonexistent.txt' ) ); 
    176         // TODO: Be smarter about this and find an actual file in a theme subdirectory. 
    177         $this->assertEquals( 'ie.css', apply_filters( 'c2c_if_theme_file_exists', 'ie.css', '%file_name%', false, 'css' ) ); 
     180        // TODO: Test finding a file in a subdirectory relative to current theme. 
     181        // (WP unit tests have no such example file to use.) 
     182        //$this->assertEquals( 'ie.css', apply_filters( 'c2c_if_theme_file_exists', 'ie.css', '%file_name%', false, 'css' ) ); 
    178183    } 
    179184 
Note: See TracChangeset for help on using the changeset viewer.