From e3f6b2b271caf115beb1fd3886dd8316bdf5cffa Mon Sep 17 00:00:00 2001
From: ryan
Date: Wed, 17 Sep 2008 00:40:10 +0000
Subject: [PATCH] phpdoc for wp-admin/includes from jacobsantos. see #7527
git-svn-id: http://svn.automattic.com/wordpress/trunk@8912 1a063a9b-81f0-0310-95a4-ce76da25c4cd
---
wp-admin/includes/comment.php | 38 ++++++-
wp-admin/includes/dashboard.php | 132 ++++++++++++++++++++---
wp-admin/includes/export.php | 76 ++++++++++++-
wp-admin/includes/image.php | 155 +++++++++++++++++----------
wp-admin/includes/media.php | 36 +++----
wp-admin/includes/plugin-install.php | 34 +++++-
wp-admin/includes/plugin.php | 139 ++++++++++++++++++++----
wp-admin/includes/post.php | 12 +--
wp-admin/includes/widgets.php | 54 ++++++++--
9 files changed, 549 insertions(+), 127 deletions(-)
diff --git a/wp-admin/includes/comment.php b/wp-admin/includes/comment.php
index 4b888002b4..50053b328b 100644
--- a/wp-admin/includes/comment.php
+++ b/wp-admin/includes/comment.php
@@ -1,4 +1,10 @@
\n\n";
@@ -205,13 +221,27 @@ function wp_dashboard() {
echo "
\n\n\n\n";
}
-// Makes sidebar_widgets option reflect the dashboard settings
+/**
+ * Makes sidebar_widgets option reflect the dashboard settings.
+ *
+ * @since unknown
+ *
+ * @return array WordPress Dashboard Widgets list.
+ */
function wp_dashboard_sidebars_widgets() { // hackery
return $GLOBALS['wp_dashboard_sidebars'];
}
// Modifies sidbar params on the fly to set up ids, class names, titles for each widget (called once per widget)
// Switches widget to edit mode if $_GET['edit']
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $params
+ * @return unknown
+ */
function wp_dashboard_dynamic_sidebar_params( $params ) {
global $wp_registered_widgets, $wp_registered_widget_controls;
@@ -483,6 +513,13 @@ function wp_dashboard_inbox( $sidebar_args ) {
echo $after_widget;
}
+/**
+ * Display recent comments dashboard widget content.
+ *
+ * @since unknown
+ *
+ * @param unknown_type $sidebar_args
+ */
function wp_dashboard_recent_comments( $sidebar_args ) {
global $comment;
extract( $sidebar_args, EXTR_SKIP );
@@ -536,7 +573,13 @@ function wp_dashboard_recent_comments( $sidebar_args ) {
echo $after_widget;
}
-// $sidebar_args are handled by wp_dashboard_empty()
+/**
+ * Display incoming links dashboard widget content.
+ *
+ * $sidebar_args are handled by wp_dashboard_empty().
+ *
+ * @since unknown
+ */
function wp_dashboard_incoming_links_output() {
$widgets = get_option( 'dashboard_widget_options' );
@extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP );
@@ -596,13 +639,29 @@ function wp_dashboard_incoming_links_output() {
}
}
-// $sidebar_args are handled by wp_dashboard_empty()
+/**
+ * {@internal Missing Short Description}}
+ *
+ * $sidebar_args are handled by wp_dashboard_empty().
+ *
+ * @since unknown
+ *
+ * @param int $widget_id
+ */
function wp_dashboard_rss_output( $widget_id ) {
$widgets = get_option( 'dashboard_widget_options' );
wp_widget_rss_output( $widgets[$widget_id] );
}
-// $sidebar_args are handled by wp_dashboard_empty()
+/**
+ * Display secondary dashboard RSS widget feed.
+ *
+ * $sidebar_args are handled by wp_dashboard_empty().
+ *
+ * @since unknown
+ *
+ * @return unknown
+ */
function wp_dashboard_secondary_output() {
$widgets = get_option( 'dashboard_widget_options' );
@extract( @$widgets['dashboard_secondary'], EXTR_SKIP );
@@ -624,7 +683,13 @@ function wp_dashboard_secondary_output() {
echo "\n
\n";
}
-// $sidebar_args are handled by wp_dashboard_empty()
+/**
+ * Display plugins most popular, newest plugins, and recently updated widget text.
+ *
+ * $sidebar_args are handled by wp_dashboard_empty().
+ *
+ * @since unknown
+ */
function wp_dashboard_plugins_output() {
$popular = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
$new = @fetch_rss( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
@@ -672,10 +737,21 @@ function wp_dashboard_plugins_output() {
}
}
-// Checks to see if all of the feed url in $check_urls are cached.
-// If $check_urls is empty, look for the rss feed url found in the dashboard widget optios of $widget_id.
-// If cached, call $callback, a function that echoes out output for this widget.
-// If not cache, echo a "Loading..." stub which is later replaced by AJAX call (see top of /wp-admin/index.php)
+/**
+ * Checks to see if all of the feed url in $check_urls are cached.
+ *
+ * If $check_urls is empty, look for the rss feed url found in the dashboard
+ * widget optios of $widget_id. If cached, call $callback, a function that
+ * echoes out output for this widget. If not cache, echo a "Loading..." stub
+ * which is later replaced by AJAX call (see top of /wp-admin/index.php)
+ *
+ * @since unknown
+ *
+ * @param int $widget_id
+ * @param callback $callback
+ * @param array $check_urls RSS feeds
+ * @return bool False on failure. True on success.
+ */
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
$loading = '' . __( 'Loading…' ) . '
';
@@ -711,8 +787,17 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
return true;
}
-// Empty widget used for JS/AJAX created output.
-// Callback inserts content between before_widget and after_widget. Used when widget is in edit mode. Can also be used for custom widgets.
+/**
+ * Empty widget used for JS/AJAX created output.
+ *
+ * Callback inserts content between before_widget and after_widget. Used when
+ * widget is in edit mode. Can also be used for custom widgets.
+ *
+ * @since unknown
+ *
+ * @param array $sidebar_args
+ * @param callback $callback Optional. Only used in edit mode.
+ */
function wp_dashboard_empty( $sidebar_args, $callback = false ) {
extract( $sidebar_args, EXTR_SKIP );
@@ -732,7 +817,7 @@ function wp_dashboard_empty( $sidebar_args, $callback = false ) {
echo $after_widget;
}
-/* Dashboard Widgets Controls. Ssee also wp_dashboard_empty() */
+/* Dashboard Widgets Controls. See also wp_dashboard_empty() */
// Temp
function wp_dashboard_empty_control() {
@@ -740,13 +825,30 @@ function wp_dashboard_empty_control() {
}
// Calls widget_control callback
+/**
+ * Calls widget control callback.
+ *
+ * @since unknown
+ *
+ * @param int $widget_control_id Registered Widget ID.
+ */
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
global $wp_registered_widget_controls;
if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_registered_widget_controls[$widget_control_id]) && is_callable($wp_registered_widget_controls[$widget_control_id]['callback']) )
call_user_func_array( $wp_registered_widget_controls[$widget_control_id]['callback'], $wp_registered_widget_controls[$widget_control_id]['params'] );
}
-// Sets up $args to be used as input to wp_widget_rss_form(), handles POST data from RSS-type widgets
+/**
+ * The RSS dashboard widget control.
+ *
+ * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
+ * from RSS-type widgets.
+ *
+ * @since unknown
+ *
+ * @param array $args Expects 'widget_id' and 'form_inputs'.
+ * @return bool|null False if no widget_id is given. Null on success.
+ */
function wp_dashboard_rss_control( $args ) {
extract( $args );
if ( !$widget_id )
diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php
index 00201fab76..c46843bd5e 100644
--- a/wp-admin/includes/export.php
+++ b/wp-admin/includes/export.php
@@ -1,8 +1,28 @@
get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_dat
$categories = (array) get_categories('get=all');
$tags = (array) get_tags('get=all');
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param unknown_type $categories
+ */
function wxr_missing_parents($categories) {
if ( !is_array($categories) || empty($categories) )
return array();
@@ -61,6 +88,13 @@ while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) {
}
unset($categories);
+/**
+ * Place string in CDATA tag.
+ *
+ * @since unknown
+ *
+ * @param string $str String to place in XML CDATA tag.
+ */
function wxr_cdata($str) {
if ( seems_utf8($str) == false )
$str = utf8_encode($str);
@@ -72,6 +106,13 @@ function wxr_cdata($str) {
return $str;
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @return string Site URL.
+ */
function wxr_site_url() {
global $current_site;
@@ -85,6 +126,13 @@ function wxr_site_url() {
}
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param object $c Category Object
+ */
function wxr_cat_name($c) {
if ( empty($c->name) )
return;
@@ -92,6 +140,13 @@ function wxr_cat_name($c) {
echo '' . wxr_cdata($c->name) . '';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param object $c Category Object
+ */
function wxr_category_description($c) {
if ( empty($c->description) )
return;
@@ -99,6 +154,13 @@ function wxr_category_description($c) {
echo '' . wxr_cdata($c->description) . '';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param object $t Tag Object
+ */
function wxr_tag_name($t) {
if ( empty($t->name) )
return;
@@ -106,6 +168,13 @@ function wxr_tag_name($t) {
echo '' . wxr_cdata($t->name) . '';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param object $t Tag Object
+ */
function wxr_tag_description($t) {
if ( empty($t->description) )
return;
@@ -113,6 +182,11 @@ function wxr_tag_description($t) {
echo '' . wxr_cdata($t->description) . '';
}
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ */
function wxr_post_taxonomy() {
$categories = get_the_category();
$tags = get_the_tags();
diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php
index 5864f87050..719729e294 100644
--- a/wp-admin/includes/image.php
+++ b/wp-admin/includes/image.php
@@ -3,41 +3,44 @@
* File contains all the administration image manipulation functions.
*
* @package WordPress
+ * @subpackage Administration
*/
/**
- * wp_create_thumbnail() - Create a thumbnail from an Image given a maximum side size.
+ * Create a thumbnail from an Image given a maximum side size.
*
- * @package WordPress
- * @param mixed $file Filename of the original image, Or attachment id
- * @param int $max_side Maximum length of a single side for the thumbnail
- * @return string Thumbnail path on success, Error string on failure
+ * This function can handle most image file formats which PHP supports. If PHP
+ * does not have the functionality to save in a file of the same format, the
+ * thumbnail will be created as a jpeg.
*
- * This function can handle most image file formats which PHP supports.
- * If PHP does not have the functionality to save in a file of the same format, the thumbnail will be created as a jpeg.
+ * @since unknown
+ *
+ * @param mixed $file Filename of the original image, Or attachment id.
+ * @param int $max_side Maximum length of a single side for the thumbnail.
+ * @return string Thumbnail path on success, Error string on failure.
*/
function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
-
$thumbpath = image_resize( $file, $max_side, $max_side );
return apply_filters( 'wp_create_thumbnail', $thumbpath );
}
/**
- * wp_crop_image() - Crop an Image to a given size.
+ * Crop an Image to a given size.
*
- * @package WordPress
* @internal Missing Long Description
- * @param int $src_file The source file
- * @param int $src_x The start x position to crop from
- * @param int $src_y The start y position to crop from
- * @param int $src_w The width to crop
- * @param int $src_h The height to crop
- * @param int $dst_w The destination width
- * @param int $dst_h The destination height
- * @param int $src_abs If the source crop points are absolute
- * @param int $dst_file The destination file to write to
- * @return string New filepath on success, String error message on failure
*
+ * @since unknown
+ *
+ * @param string|int $src_file The source file or Attachment ID
+ * @param int $src_x The start x position to crop from.
+ * @param int $src_y The start y position to crop from.
+ * @param int $src_w The width to crop.
+ * @param int $src_h The height to crop.
+ * @param int $dst_w The destination width.
+ * @param int $dst_h The destination height.
+ * @param int $src_abs Optional. If the source crop points are absolute.
+ * @param string $dst_file Optional. The destination file to write to.
+ * @return string New filepath on success, String error message on failure.
*/
function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
if ( is_numeric( $src_file ) ) // Handle int as attachment ID
@@ -74,14 +77,15 @@ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_
}
/**
- * wp_generate_attachment_metadata() - Generate post Image attachment Metadata
+ * Generate post Image attachment Metadata.
*
- * @package WordPress
* @internal Missing Long Description
- * @param int $attachment_id Attachment Id to process
- * @param string $file Filepath of the Attached image
- * @return mixed Metadata for attachment
*
+ * @since unknown
+ *
+ * @param int $attachment_id Attachment Id to process
+ * @param string $file Filepath of the Attached image
+ * @return mixed Metadata for attachment
*/
function wp_generate_attachment_metadata( $attachment_id, $file ) {
$attachment = get_post( $attachment_id );
@@ -120,17 +124,19 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
$metadata['image_meta'] = $image_meta;
}
+
return apply_filters( 'wp_generate_attachment_metadata', $metadata );
}
/**
- * wp_load_image() - Load an image which PHP Supports.
+ * Load an image which PHP Supports.
*
- * @package WordPress
* @internal Missing Long Description
- * @param string $file Filename of the image to load
- * @return resource The resulting image resource on success, Error string on failure.
*
+ * @since unknown
+ *
+ * @param string $file Filename of the image to load.
+ * @return resource The resulting image resource on success, Error string on failure.
*/
function wp_load_image( $file ) {
if ( is_numeric( $file ) )
@@ -153,36 +159,45 @@ function wp_load_image( $file ) {
}
/**
- * get_udims() - Calculated the new dimentions for downsampled images
+ * Calculated the new dimentions for downsampled images.
*
- * @package WordPress
- * @internal Missing Description
+ * @since unknown
* @see wp_shrink_dimensions()
- * @param int $width Current width of the image
- * @param int $height Current height of the image
- * @return mixed Array(height,width) of shrunk dimensions.
+ *
+ * @param int $width Current width of the image
+ * @param int $height Current height of the image
+ * @return mixed Array(height,width) of shrunk dimensions.
*
*/
function get_udims( $width, $height) {
return wp_shrink_dimensions( $width, $height );
}
+
/**
- * wp_shrink_dimensions() - Calculates the new dimentions for a downsampled image.
+ * Calculates the new dimentions for a downsampled image.
*
- * @package WordPress
- * @internal Missing Long Description
- * @param int $width Current width of the image
- * @param int $height Current height of the image
- * @param int $wmax Maximum wanted width
- * @param int $hmax Maximum wanted height
- * @return mixed Array(height,width) of shrunk dimensions.
+ * @since unknown
+ * @see wp_constrain_dimensions()
+ *
+ * @param int $width Current width of the image
+ * @param int $height Current height of the image
+ * @param int $wmax Maximum wanted width
+ * @param int $hmax Maximum wanted height
+ * @return mixed Array(height,width) of shrunk dimensions.
*
*/
function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
}
-// convert a fraction string to a decimal
+/**
+ * Convert a fraction string to a decimal.
+ *
+ * @since unknown
+ *
+ * @param string $str
+ * @return int|float
+ */
function wp_exif_frac2dec($str) {
@list( $n, $d ) = explode( '/', $str );
if ( !empty($d) )
@@ -190,25 +205,39 @@ function wp_exif_frac2dec($str) {
return $str;
}
-// convert the exif date format to a unix timestamp
+/**
+ * Convert the exif date format to a unix timestamp.
+ *
+ * @since unknown
+ *
+ * @param string $str
+ * @return int
+ */
function wp_exif_date2ts($str) {
- // seriously, who formats a date like 'YYYY:MM:DD hh:mm:ss'?
@list( $date, $time ) = explode( ' ', trim($str) );
@list( $y, $m, $d ) = explode( ':', $date );
return strtotime( "{$y}-{$m}-{$d} {$time}" );
}
-// get extended image metadata, exif or iptc as available
+/**
+ * Get extended image metadata, exif or iptc as available
+ *
+ * @since unknown
+ *
+ * @param string $file
+ * @return bool|array False on failure. Image metadata array on success.
+ */
function wp_read_image_metadata( $file ) {
if ( !file_exists( $file ) )
return false;
list(,,$sourceImageType) = getimagesize( $file );
- // exif contains a bunch of data we'll probably never need formatted in ways that are difficult to use.
- // We'll normalize it and just extract the fields that are likely to be useful. Fractions and numbers
- // are converted to floats, dates to unix timestamps, and everything else to strings.
+ // exif contains a bunch of data we'll probably never need formatted in ways
+ // that are difficult to use. We'll normalize it and just extract the fields
+ // that are likely to be useful. Fractions and numbers are converted to
+ // floats, dates to unix timestamps, and everything else to strings.
$meta = array(
'aperture' => 0,
'credit' => '',
@@ -222,7 +251,8 @@ function wp_read_image_metadata( $file ) {
'title' => '',
);
- // read iptc first, since it might contain data not available in exif such as caption, description etc
+ // read iptc first, since it might contain data not available in exif such
+ // as caption, description etc
if ( is_callable('iptcparse') ) {
getimagesize($file, $info);
if ( !empty($info['APP13']) ) {
@@ -231,7 +261,7 @@ function wp_read_image_metadata( $file ) {
$meta['credit'] = utf8_encode(trim($iptc['2#110'][0]));
elseif ( !empty($iptc['2#080'][0]) ) // byline
$meta['credit'] = utf8_encode(trim($iptc['2#080'][0]));
- if ( !empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0]) ) // created datee and time
+ if ( !empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0]) ) // created date and time
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
if ( !empty($iptc['2#120'][0]) ) // caption
$meta['caption'] = utf8_encode(trim($iptc['2#120'][0]));
@@ -258,19 +288,34 @@ function wp_read_image_metadata( $file ) {
if (!empty($exif['ExposureTime']))
$meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] );
}
- // FIXME: try other exif libraries if available
+ /** @todo FIXME: try other exif libraries if available */
return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
}
-// is the file a real image file?
+/**
+ * Validate that file is an image.
+ *
+ * @since unknown
+ *
+ * @param string $path File path to test if valid image.
+ * @return bool True if valid image, false if not valid image.
+ */
function file_is_valid_image($path) {
$size = @getimagesize($path);
return !empty($size);
}
-// is the file an image suitable for displaying within a web page?
+/**
+ * Validate that file is suitable for displaying within a web page.
+ *
+ * @since unknown
+ * @uses apply_filters() Calls 'file_is_displayable_image' on $result and $path.
+ *
+ * @param string $path File path to test.
+ * @return bool True if suitable, false if not suitable.
+ */
function file_is_displayable_image($path) {
$info = @getimagesize($path);
if ( empty($info) )
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index bb299236cc..a6a837f26b 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -691,7 +691,7 @@ function get_attachment_fields_to_edit($post, $errors = null) {
'html' => image_link_input_fields($post, get_option('image_default_link_type')),
'helps' => __('Enter a link URL or click above for presets.'),
),
- 'menu_order' => array(
+ 'menu_order' => array(
'label' => __('Order'),
'value' => $edit_post->menu_order
),
@@ -1491,31 +1491,31 @@ function type_form_file() {
// support a GET parameter for disabling the flash uploader
function media_upload_use_flash($flash) {
- if ( array_key_exists('flash', $_REQUEST) )
- $flash = !empty($_REQUEST['flash']);
- return $flash;
+ if ( array_key_exists('flash', $_REQUEST) )
+ $flash = !empty($_REQUEST['flash']);
+ return $flash;
}
add_filter('flash_uploader', 'media_upload_use_flash');
function media_upload_flash_bypass() {
- echo '';
- printf( __('You are using the Flash uploader. Problems? Try the Browser uploader instead.'), clean_url(add_query_arg('flash', 0)) );
- echo '
';
+ echo '';
+ printf( __('You are using the Flash uploader. Problems? Try the Browser uploader instead.'), clean_url(add_query_arg('flash', 0)) );
+ echo '
';
}
add_action('post-flash-upload-ui', 'media_upload_flash_bypass');
function media_upload_html_bypass() {
- echo '';
- if ( array_key_exists('flash', $_REQUEST) )
- // the user manually selected the browser uploader, so let them switch back to Flash
- printf( __('You are using the Browser uploader. Try the Flash uploader instead.'), clean_url(add_query_arg('flash', 1)) );
- else
- // the user probably doesn't have Flash
- printf( __('You are using the Browser uploader.') );
+ echo '
';
+ if ( array_key_exists('flash', $_REQUEST) )
+ // the user manually selected the browser uploader, so let them switch back to Flash
+ printf( __('You are using the Browser uploader. Try the Flash uploader instead.'), clean_url(add_query_arg('flash', 1)) );
+ else
+ // the user probably doesn't have Flash
+ printf( __('You are using the Browser uploader.') );
- echo '
';
+ echo '
';
}
add_action('post-flash-upload-ui', 'media_upload_flash_bypass');
@@ -1523,9 +1523,9 @@ add_action('post-html-upload-ui', 'media_upload_html_bypass');
// make sure the GET parameter sticks when we submit a form
function media_upload_bypass_url($url) {
- if ( array_key_exists('flash', $_REQUEST) )
- $url = add_query_arg('flash', intval($_REQUEST['flash']));
- return $url;
+ if ( array_key_exists('flash', $_REQUEST) )
+ $url = add_query_arg('flash', intval($_REQUEST['flash']));
+ return $url;
}
add_filter('media_upload_form_url', 'media_upload_bypass_url');
diff --git a/wp-admin/includes/plugin-install.php b/wp-admin/includes/plugin-install.php
index e7242b8191..0c330dfa54 100644
--- a/wp-admin/includes/plugin-install.php
+++ b/wp-admin/includes/plugin-install.php
@@ -1,6 +1,30 @@
timeout + 3 * 60 * 60 > time() )
return $cache->cached;
diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php
index 77b30d4656..3a93fcf141 100644
--- a/wp-admin/includes/plugin.php
+++ b/wp-admin/includes/plugin.php
@@ -96,6 +96,26 @@ function get_plugin_data( $plugin_file ) {
);
}
+/**
+ * Check the plugins directory and retrieve all plugin files with plugin data.
+ *
+ * WordPress only supports plugin files in the base plugins directory
+ * (wp-content/plugins) and in one directory above the plugins directory
+ * (wp-content/plugins/my-plugin). The file it looks for has the plugin data and
+ * must be found in those two locations. It is recommended that do keep your
+ * plugin files in directories.
+ *
+ * The file with the plugin data is the file that will be included and therefore
+ * needs to have the main execution for the plugin. This does not mean
+ * everything must be contained in the file and it is recommended that the file
+ * be split for maintainability. Keep everything in one file for extreme
+ * optimization purposes.
+ *
+ * @since unknown
+ *
+ * @param string $plugin_folder Optional. Relative path to single plugin folder.
+ * @return array Key is the plugin file path and the value is an array of the plugin data.
+ */
function get_plugins($plugin_folder = '') {
if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') )
@@ -169,29 +189,64 @@ function is_plugin_active($plugin) {
return in_array($plugin, get_option('active_plugins'));
}
+/**
+ * Attempts activation of plugin in a "sandbox" and redirects on success.
+ *
+ * A plugin that is already activated will not attempt to be activated again.
+ *
+ * The way it works is by setting the redirection to the error before trying to
+ * include the plugin file. If the plugin fails, then the redirection will not
+ * be overwritten with the success message. Also, the options will not be
+ * updated and the activation hook will not be called on plugin error.
+ *
+ * It should be noted that in no way the below code will actually prevent errors
+ * within the file. The code should not be used elsewhere to replicate the
+ * "sandbox", which uses redirection to work.
+ * {@source 13 1}
+ *
+ * If any errors are found or text is outputted, then it will be captured to
+ * ensure that the success redirection will update the error redirection.
+ *
+ * @since unknown
+ *
+ * @param string $plugin Plugin path to main plugin file with plugin data.
+ * @param string $redirect Optional. URL to redirect to.
+ * @return WP_Error|null WP_Error on invalid file or null on success.
+ */
function activate_plugin($plugin, $redirect = '') {
- $current = get_option('active_plugins');
- $plugin = trim($plugin);
+ $current = get_option('active_plugins');
+ $plugin = trim($plugin);
- $valid = validate_plugin($plugin);
- if ( is_wp_error($valid) )
- return $valid;
+ $valid = validate_plugin($plugin);
+ if ( is_wp_error($valid) )
+ return $valid;
- if ( !in_array($plugin, $current) ) {
- if ( !empty($redirect) )
- wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
- ob_start();
- @include(WP_PLUGIN_DIR . '/' . $plugin);
- $current[] = $plugin;
- sort($current);
- update_option('active_plugins', $current);
- do_action('activate_' . $plugin);
- ob_end_clean();
- }
+ if ( !in_array($plugin, $current) ) {
+ if ( !empty($redirect) )
+ wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
+ ob_start();
+ @include(WP_PLUGIN_DIR . '/' . $plugin);
+ $current[] = $plugin;
+ sort($current);
+ update_option('active_plugins', $current);
+ do_action('activate_' . $plugin);
+ ob_end_clean();
+ }
- return null;
+ return null;
}
+/**
+ * Deactivate a single plugin or multiple plugins.
+ *
+ * The deactivation hook is disabled by the plugin upgrader by using the $silent
+ * parameter.
+ *
+ * @since unknown
+ *
+ * @param string|array $plugins Single plugin or list of plugins to deactivate.
+ * @param bool $silent Optional, default is false. Prevent calling deactivate hook.
+ */
function deactivate_plugins($plugins, $silent= false) {
$current = get_option('active_plugins');
@@ -209,6 +264,20 @@ function deactivate_plugins($plugins, $silent= false) {
update_option('active_plugins', $current);
}
+/**
+ * Activate multiple plugins.
+ *
+ * When WP_Error is returned, it does not mean that one of the plugins had
+ * errors. It means that one or more of the plugins file path was invalid.
+ *
+ * The execution will be halted as soon as one of the plugins has an error.
+ *
+ * @since unknown
+ *
+ * @param string|array $plugins
+ * @param string $redirect Redirect to page after successful activation.
+ * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
+ */
function activate_plugins($plugins, $redirect = '') {
if ( !is_array($plugins) )
$plugins = array($plugins);
@@ -228,6 +297,18 @@ function activate_plugins($plugins, $redirect = '') {
return true;
}
+/**
+ * Remove directory and files of a plugin for a single or list of plugin(s).
+ *
+ * If the plugins parameter list is empty, false will be returned. True when
+ * completed.
+ *
+ * @since unknown
+ *
+ * @param array $plugins List of plugin
+ * @param string $redirect Redirect to page when complete.
+ * @return mixed
+ */
function delete_plugins($plugins, $redirect = '' ) {
global $wp_filesystem;
@@ -331,6 +412,16 @@ function validate_active_plugins() {
return $invalid;
}
+/**
+ * Validate the plugin path.
+ *
+ * Checks that the file exists and {@link validate_file() is valid file}.
+ *
+ * @since unknown
+ *
+ * @param string $plugin Plugin Path
+ * @return WP_Error|int 0 on success, WP_Error on failure.
+ */
function validate_plugin($plugin) {
if ( validate_file($plugin) )
return new WP_Error('plugin_invalid', __('Invalid plugin path.'));
@@ -343,7 +434,7 @@ function validate_plugin($plugin) {
/**
* Whether the plugin can be uninstalled.
*
- * @since 2.7
+ * @since 2.7.0
*
* @param string $plugin Plugin path to check.
* @return bool Whether plugin can be uninstalled.
@@ -363,7 +454,7 @@ function is_uninstallable_plugin($plugin) {
*
* Calls the uninstall hook, if it is available.
*
- * @since 2.7
+ * @since 2.7.0
*
* @param string $plugin Relative plugin path from Plugin Directory.
*/
@@ -454,6 +545,16 @@ function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $fi
return $hookname;
}
+/**
+ * Add sub menu page to the management main menu.
+ *
+ * @param string $page_title
+ * @param unknown_type $menu_title
+ * @param unknown_type $access_level
+ * @param unknown_type $file
+ * @param unknown_type $function
+ * @return unknown
+ */
function add_management_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
return add_submenu_page( 'edit.php', $page_title, $menu_title, $access_level, $file, $function );
}
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index f4ff52afad..e4b62d7af7 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -1,7 +1,7 @@
'.$post_title.''."\n$text";
- }
+ $post_content = ''.$post_title.''."\n$text";
+ }
if ( !empty( $_REQUEST['excerpt'] ) )
$post_excerpt = wp_specialchars( stripslashes( $_REQUEST['excerpt'] ));
@@ -226,9 +226,9 @@ function get_default_post_to_edit() {
}
function get_default_page_to_edit() {
- $page = get_default_post_to_edit();
- $page->post_type = 'page';
- return $page;
+ $page = get_default_post_to_edit();
+ $page->post_type = 'page';
+ return $page;
}
// Get an existing post and format it for editing.
diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php
index f936e52ba4..f7dc77f97c 100644
--- a/wp-admin/includes/widgets.php
+++ b/wp-admin/includes/widgets.php
@@ -1,6 +1,19 @@
@@ -163,7 +181,14 @@ function wp_list_widget_controls( $sidebar ) {
+?>
\ No newline at end of file