-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadme.txt
More file actions
141 lines (96 loc) · 7.87 KB
/
readme.txt
File metadata and controls
141 lines (96 loc) · 7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
=== If File Exists ===
Contributors: coffee2code
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6ARCFJ9TX3522
Tags: file, exists, existence, filesystem, coffee2code
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires at least: 2.7
Tested up to: 6.8
Stable tag: 2.4
Check if a file exists and return true/false or display a string containing information about the file.
== Description ==
This 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.
* If a format string is not passed to it, the functions returns a simple boolean (true or false) indicating if the specified file exists.
* 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 directory, extension, name, path, size, or url). 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.
By 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.
Links: [Plugin Homepage](https://coffee2code.com/wp-plugins/if-file-exists/) | [Plugin Directory Page](https://wordpress.org/plugins/if-file-exists/) | [GitHub](https://github.com/coffee2code/if-file-exists/) | [Author Homepage](https://coffee2code.com)
== Installation ==
1. Install via the built-in WordPress plugin installer. Or install the plugin code inside the plugins directory for your site (typically `/wp-content/plugins/`).
2. Activate the plugin through the 'Plugins' admin menu in WordPress
3. In one or more of your templates, utilize one of the template tags provided by this plugin (see examples)
== Developer Documentation ==
Developer documentation can be found in [DEVELOPER-DOCS.md](https://github.com/coffee2code/if-file-exists/blob/master/DEVELOPER-DOCS.md). That documentation covers the template tags and hooks provided by the plugin.
As an overview, these are the template tags provided by the plugin:
* `c2c_if_file_exists()` : Checks if a file exists and returns true/false or displays a string containing information about the file.
* `c2c_if_plugin_file_exists()` : Checks if a file exists (relative to the plugins directory) and returns true/false or displays a string containing information about the file.
* `c2c_if_theme_file_exists()` : Checks if a file exists (relative to the current theme's directory) and returns true/false or displays a string containing information about the file. If the current theme is a child theme, then the function will check if the file exists first in the child theme's directory, and if not there, then it will check the parent theme's directory.
These are the hooks provided by the plugin:
* `c2c_if_file_exists` : Filter that allows use of an alternative approach to safely invoke `c2c_if_file_exists()` in such a way that if the plugin were deactivated or deleted, then your calls to the function won't cause errors in your site.
* `c2c_if_plugin_file_exists` : Filter that allows use of an alternative approach to safely invoke `c2c_if_plugin_file_exists()` in such a way that if the plugin were deactivated or deleted, then your calls to the function won't cause errors in your site.
* `c2c_if_theme_file_exists` : Filter that allows use of an alternative approach to safely invoke `c2c_if_theme_file_exists()` in such a way that if the plugin were deactivated or deleted, then your calls to the function won't cause errors in your site.
== Changelog ==
= 2.4 (2025-04-18) =
* New: Add '%file_size%' and '%file_size_bytes%' as additional substitution tags
* Change: Escape `$format` and `$show_if_not_exists` values prior to display to omit unsafe markup
* Change: Discontinue unnecessary explicit loading of textdomain
* Change: Note compatibility through WP 6.8+
* Change: Note compatibility through PHP 8.3+
* Change: Update copyright date (2025)
* Unit tests:
* Change: Change test class name to match plugin name
= 2.3.2 (2024-08-02) =
* Change: Note compatibility through WP 6.6+
* Change: Update copyright date (2024)
* New: Add `.gitignore` file
* Change: Remove development and testing-related files from release packaging
* Unit tests:
* Hardening: Prevent direct web access to `bootstrap.php`
* Allow tests to run against current versions of WordPress
* New: Add `composer.json` for PHPUnit Polyfill dependency
* Change: In bootstrap, store path to plugin directory in a constant
= 2.3.1 (2023-05-18) =
* Change: Note compatibility through WP 6.3+
* Change: Update copyright date (2023)
* New: Add a potential TODO item
_Full changelog is available in [CHANGELOG.md](https://github.com/coffee2code/if-file-exists/blob/master/CHANGELOG.md)._
== Upgrade Notice ==
= 2.4 =
Minor update: added '%file_size%' and '%file_size_bytes%' substitution tags, escaped output before display to prevent unsafe markup, noted compatibility through WP 6.8+ and PHP 8.3+, and updated copyright date (2025)
= 2.3.2 =
Trivial update: noted compatibility through WP 6.6+, removed unit tests from release packaging, and updated copyright date (2024)
= 2.3.1 =
Trivial update: noted compatibility through WP 6.3+ and updated copyright date (2023)
= 2.3 =
Minor update: removed support for long-deprecated `if_file_exists()`, added DEVELOPER-DOCS.md, noted compatibility through WP 5.8+, and minor reorganization and tweaks to unit tests
= 2.2.10 =
Trivial update: noted compatibility through WP 5.7+ and updated copyright date (2021)
= 2.2.9 =
Trivial update: Restructured unit test file structure and noted compatibility through WP 5.5+.
= 2.2.8 =
Trivial update: Fixed a link in readme.txt, updated a few URLs to be HTTPS and noted compatibility through WP 5.4+.
= 2.2.7 =
Trivial update: noted compatibility through WP 5.3+ and updated copyright date (2020).
= 2.2.6 =
Trivial update: created CHANGELOG.md to store historical changelog outside of readme.txt, noted compatibility through WP 5.1+, and updated copyright date (2019)
= 2.2.5 =
Trivial update: noted compatibility through WP 4.9+, added README.md for GitHub, updated copyright date (2018), and other minor changes
= 2.2.4 =
Trivial update: fixed some unit tests, noted compatibility through WP 4.7+, updated copyright date
= 2.2.3 =
Trivial update: improved support for localization, minor unit test tweaks, verified compatibility through WP 4.4+, and updated copyright date (2016)
= 2.2.2 =
Trivial update: noted compatibility through WP 4.1+ and updated copyright date (2015)
= 2.2.1 =
Trivial update: noted compatibility through WP 4.0+; added plugin icon.
= 2.2 =
Recommended minor update: fixed a few minor bugs; added unit tests; noted compatibility through WP 3.8+
= 2.1.3 =
Trivial update: noted compatibility through WP 3.5+; minor documentation changes
= 2.1.2 =
Trivial update: noted compatibility through WP 3.4+; explicitly stated license
= 2.1.1 =
Trivial update: noted compatibility through WP 3.3+ and minor readme.txt tweaks
= 2.1 =
Recommended minor update. Highlights: fixed a few minor bugs, added tests, clarified/updated some documentation, and verified compatibility with WordPress 3.2.
= 2.0 =
Recommended feature update. Highlights: added c2c_if_plugin_file_exists() and c2c_if_theme_file_exists(); added %file_directory% and %file_extension%; added hooks for customization; minor fixes and tweaks; renamed blog_time() to c2c_blog_time(); renamed class; verified WP 3.0 compatibility.