PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 1.4.2
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v1.4.2
2.45.0 2.44.0 trunk 1.10 1.10.1 1.4.1 1.4.10 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.7 1.5.8 1.5.9 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.8.1 1.9 1.9.10 1.9.12 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.9 2.0 2.0.2 2.0.3 2.1 2.1.1 2.10.0 2.10.1 2.10.2 2.10.3 2.11.1 2.12.1 2.12.2 2.13.0 2.14.0 2.15.0 2.16.0 2.17.0 2.18.0 2.18.2 2.19.0 2.19.1 2.19.2 2.2 2.2.1 2.20.0 2.21.0 2.22.0 2.23.0 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.30.0 2.31.0 2.32.0 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.40.0 2.41.0 2.42.0 2.43.0 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.7.0 2.7.1 2.8.0 2.8.1 2.9.0 2.9.1
capability-manager-enhanced / framework / lib / modules.php
capability-manager-enhanced / framework / lib Last commit date
filesystem.php 13 years ago formating.php 13 years ago modules.php 13 years ago objects.php 13 years ago plugins.php 13 years ago system.php 13 years ago themes.php 13 years ago users.php 13 years ago
modules.php
208 lines
1 <?php
2 /**
3 * Modules related functions.
4 *
5 * @version $Rev: 203758 $
6 * @author Jordi Canals
7 * @copyright Copyright (C) 2008, 2009, 2010 Jordi Canals
8 * @license GNU General Public License version 2
9 * @link http://alkivia.org
10 * @package Alkivia
11 * @subpackage Framework
12 *
13
14 Copyright 2008, 2009, 2010 Jordi Canals <devel@jcanals.cat>
15
16 This program is free software; you can redistribute it and/or
17 modify it under the terms of the GNU General Public License
18 version 2 as published by the Free Software Foundation.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 */
28
29 /**
30 * Parse the plugin readme.txt file to retrieve plugin's metadata.
31 *
32 * The metadata of the plugin's readme searches for the following in the readme.txt
33 * header. All metadata must be on its own line. The below is formatted for printing.
34 *
35 * <code>
36 * Contributors: contributors nicknames, comma delimited
37 * Donate link: Link to plugin donate page
38 * Tags: Plugin tags, comma delimited
39 * Requires at least: Minimum WordPress version required
40 * Tested up to: Higher WordPress version the plugin has been tested.
41 * Stable tag: Latest stable tag in repository.
42 * </code>
43 *
44 * Readme data returned array cointains the following:
45 * - 'Contributors' - An array with all contributors nicknames.
46 * - 'Tags' - An array with all plugin tags.
47 * - 'DonateURI' - The donations page address.
48 * - 'HelpURI' - Link to the forum page.
49 * - 'DocsURI' - Link to module documentation.
50 * - 'Required' - Minimum required WordPress version.
51 * - 'Tested' - Higher WordPress version this plugin has been tested.
52 * - 'Stable' - Last stable tag when this was released.
53 *
54 * The first 8kiB of the file will be pulled in and if the readme data is not
55 * within that first 8kiB, then the plugin author should correct their plugin
56 * and move the plugin data headers to the top.
57 *
58 * The readme file is assumed to have permissions to allow for scripts to read
59 * the file. This is not checked however and the file is only opened for
60 * reading.
61 *
62 * @param string $mod_file Path to the plugin file (not the readme file)
63 * @return array See above for description.
64 */
65 function ak_module_readme_data( $mod_file )
66 {
67 $file = dirname($mod_file) . '/readme.txt';
68
69 if ( is_readable($file) ) {
70 $fp = fopen($file, 'r'); // Open just for reading.
71 $data = fread( $fp, 8192 ); // Pull the first 8kiB of the file in.
72 fclose($fp); // Close the file.
73
74 preg_match( '|Contributors:(.*)$|mi', $data, $contributors );
75 preg_match( '|Donate link:(.*)$|mi', $data, $uri );
76 preg_match( '|Help link:(.*)$|mi', $data, $help ); // Not WP Standard
77 preg_match( '|Docs link:(.*)$|mi', $data, $docs ); // Not WP Standard
78 preg_match( '|Tags:(.*)|mi', $data, $tags );
79 preg_match( '|Requires at least:(.*)$|mi', $data, $required );
80 preg_match( '|Tested up to:(.*)$|mi', $data, $tested );
81 preg_match( '|Stable tag:(.*)$|mi', $data, $stable );
82
83 foreach ( array( 'contributors', 'uri', 'help', 'docs', 'tags', 'required', 'tested', 'stable' ) as $field ) {
84 if ( !empty( ${$field} ) ) {
85 ${$field} = trim(${$field}[1]);
86 } else {
87 ${$field} = '';
88 }
89 }
90
91 $readme_data = array(
92 'Contributors' => array_map('trim', explode(',', $contributors)),
93 'Tags' => array_map('trim', explode(',', $tags)),
94 'DonateURI' => trim($uri),
95 'HelpURI' => $help,
96 'DocsURI' => $docs,
97 'Requires' => trim($required),
98 'Tested' => trim($tested),
99 'Stable' => trim($stable) );
100 } else {
101 $readme_data = array();
102 }
103
104 return $readme_data;
105 }
106
107 /**
108 * Reads a component file header, and returns component data.
109 * Returned data is:
110 * - 'File' - The component filename, relative to the plugin folder.
111 * - 'Component' - The component short name or ID.
112 * - 'Name' - Descriptive name for the component.
113 * - 'Description' - A descriptive text about the component.
114 * - 'Author' - Component author name
115 * - 'URL' - Author homepage URL.
116 * - 'Link' - Author anchor to home page.
117 * - 'Core' - If this is a core compoment or not.
118 *
119 * @since 0.7
120 *
121 * @param string $file File name to read the header
122 * @param $is_core If will return data for core components or not.
123 * @return array Component data, see above.
124 */
125 function ak_component_data ( $file, $is_core = false )
126 {
127 $fp = fopen($file, 'r'); // Open just for reading.
128 $data = fread( $fp, 8192 ); // Pull the first 8kiB of the file in.
129 fclose($fp); // Close the file.
130
131 preg_match( '|Module Component:(.*)$|mi', $data, $component );
132 if ( empty($component) && $is_core ) {
133 preg_match( '|Core Component:(.*)$|mi', $data, $component );
134 $core = 1;
135 } else {
136 $core = 0;
137 }
138 preg_match( '|Parent ID:(.*)$|mi', $data, $parent );
139 preg_match( '|Component Name:(.*)$|mi', $data, $name );
140 preg_match( '|Description:(.*)|mi', $data, $description );
141 preg_match( '|Version:(.*)|mi', $data, $version );
142 preg_match( '|Author:(.*)|mi', $data, $author );
143 preg_match( '|Link:(.*)|mi', $data, $url );
144
145 foreach ( array( 'component', 'parent', 'name', 'description', 'version', 'author', 'url' ) as $field ) {
146 if ( ! empty( ${$field} ) ) {
147 ${$field} = trim(${$field}[1]);
148 } else {
149 ${$field} = '';
150 }
151 }
152
153 if ( empty($component) ) {
154 $data = false;
155 } else {
156 $data = array(
157 'Component' => str_replace(' ', '_', strtolower($component)),
158 'File' => $file,
159 'Parent' => $parent,
160 'Name' => $name,
161 'Description' => $description,
162 'Version' => $version,
163 'Author' => $author,
164 'URL' => $url,
165 'Link' => "<a href='{$url}' target='_blank'>{$author}</a>",
166 'Core' => $core);
167 }
168
169 return $data;
170 }
171
172 /**
173 * Gets information about all optional installed components.
174 * The function is recursive to find files in all directory levels.
175 *
176 * TODO: Path must be provided as AOC_PATH is only for community plugin.
177 * @since 0.7
178 *
179 * @param string $path Absolute path where to search for components.
180 * @param boolean $core If we want to include the core components or not.
181 * @param array $files An array with filenames to seach information in. If empty will search on $path.
182 * @return array Array with all found components information.
183 */
184 function ak_get_installed_components( $path, $core = false, $files = array() )
185 {
186 if ( empty($files) ) {
187 $files = ak_dir_content($path, 'extensions=php');
188 }
189
190 $components = array();
191 foreach ( $files as $subdir => $file ) {
192 if ( is_array($file) ) {
193 $newdir = $path .'/'. $subdir;
194 $data = ak_get_installed_components( $newdir, $core, $file );
195 if ( is_array($data) ) {
196 $components = array_merge($components, $data);
197 }
198 } else {
199 $data = ak_component_data($path . '/' . $file, $core);
200 if ( is_array($data) ) {
201 $components[$data['Component']] = $data;
202 }
203 }
204 }
205
206 return $components;
207 }
208