phpdoc for wp-admin/includes from jacobsantos. see #7527

git-svn-id: http://svn.automattic.com/wordpress/trunk@8912 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-09-17 00:40:10 +00:00
parent 86db7961b7
commit e3f6b2b271
9 changed files with 549 additions and 127 deletions

View File

@ -1,4 +1,10 @@
<?php
/**
* WordPress Comment Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* {@internal Missing Short Description}}
@ -18,8 +24,9 @@ function comment_exists($comment_author, $comment_date) {
}
/**
* {@internal Missing Short Description}}
*
*
* @since unknown
*/
function edit_comment() {
@ -42,7 +49,6 @@ function edit_comment() {
}
}
if (!empty ( $_POST['edit_date'] ) ) {
$aa = $_POST['aa'];
$mm = $_POST['mm'];
@ -60,6 +66,14 @@ function edit_comment() {
wp_update_comment( $_POST);
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $id
* @return unknown
*/
function get_comment_to_edit( $id ) {
if ( !$comment = get_comment($id) )
return false;
@ -78,6 +92,15 @@ function get_comment_to_edit( $id ) {
return $comment;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
* @uses $wpdb
*
* @param int $post_id Post ID
* @return unknown
*/
function get_pending_comments_num( $post_id ) {
global $wpdb;
@ -104,8 +127,15 @@ function get_pending_comments_num( $post_id ) {
return $pending_keyed;
}
// Add avatars to relevant places in admin, or try to
/**
* Add avatars to relevant places in admin, or try to.
*
* @since unknown
* @uses $comment
*
* @param string $name User name.
* @return string Avatar with Admin name.
*/
function floated_admin_avatar( $name ) {
global $comment;

View File

@ -1,6 +1,18 @@
<?php
/**
* WordPress Dashboard Widget Administration Panel API
*
* @package WordPress
* @subpackage Administration
*/
// Registers dashboard widgets, handles POST data, sets up filters
/**
* Registers dashboard widgets.
*
* handles POST data, sets up filters.
*
* @since unknown
*/
function wp_dashboard_setup() {
global $wpdb, $wp_dashboard_sidebars;
$update = false;
@ -193,7 +205,11 @@ function wp_dashboard_setup() {
update_option( 'dashboard_widget_options', $widget_options );
}
// Echoes out the dashboard
/**
* Displays the dashboard.
*
* @since unknown
*/
function wp_dashboard() {
echo "<div id='dashboard-widgets'>\n\n";
@ -205,13 +221,27 @@ function wp_dashboard() {
echo "<br class='clear' />\n</div>\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 "</ul>\n<br class='clear' />\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 = '<p class="widget-loading">' . __( 'Loading&#8230;' ) . '</p>';
@ -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 )

View File

@ -1,8 +1,28 @@
<?php
/**
* WordPress Export Administration API
*
* @package WordPress
* @subpackage Administration
*/
// version number for the export format. bump this when something changes that might affect compatibility.
/**
* Version number for the export format.
*
* Bump this when something changes that might affect compatibility.
*
* @since unknown
* @var string
*/
define('WXR_VERSION', '1.0');
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $author
*/
function export_wp($author='') {
global $wpdb, $post_ids, $post;
@ -26,6 +46,13 @@ $post_ids = $wpdb->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 '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_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 '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_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 '<wp:tag_name>' . wxr_cdata($t->name) . '</wp:tag_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 '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*/
function wxr_post_taxonomy() {
$categories = get_the_category();
$tags = get_the_tags();

View File

@ -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) )

View File

@ -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 '<p class="upload-flash-bypass">';
printf( __('You are using the Flash uploader. Problems? Try the <a href="%s">Browser uploader</a> instead.'), clean_url(add_query_arg('flash', 0)) );
echo '</p>';
echo '<p class="upload-flash-bypass">';
printf( __('You are using the Flash uploader. Problems? Try the <a href="%s">Browser uploader</a> instead.'), clean_url(add_query_arg('flash', 0)) );
echo '</p>';
}
add_action('post-flash-upload-ui', 'media_upload_flash_bypass');
function media_upload_html_bypass() {
echo '<p class="upload-html-bypass">';
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 <a href="%s">Flash uploader</a> instead.'), clean_url(add_query_arg('flash', 1)) );
else
// the user probably doesn't have Flash
printf( __('You are using the Browser uploader.') );
echo '<p class="upload-html-bypass">';
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 <a href="%s">Flash uploader</a> instead.'), clean_url(add_query_arg('flash', 1)) );
else
// the user probably doesn't have Flash
printf( __('You are using the Browser uploader.') );
echo '</p>';
echo '</p>';
}
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');

View File

@ -1,6 +1,30 @@
<?php
/**
* WordPress Plugin Install Administration API
*
* @package WordPress
* @subpackage Administration
*/
function plugins_api($action, $args = NULL) {
/**
* Retrieve plugin installer pages from WordPress Plugins API.
*
* It is possible for a plugin to override the Plugin API result with three
* filters. Assume this is for plugins, which can extend on the Plugin Info to
* offer more choices. This is very powerful and must be used with care, when
* overridding the filters.
*
* The first filter, 'plugins_api_args', is for the args and gives the action as
* the second parameter. The hook for 'plugins_api_args' must ensure that an
* object is returned.
*
* The second filter, 'plugins_api', is the result that would be returned.
*
* @param string $action
* @param array|object $args Optional. Arguments to serialize for the Plugin Info API.
* @return mixed
*/
function plugins_api($action, $args = null) {
global $wp_version;
if( is_array($args) )
@ -19,9 +43,15 @@ function plugins_api($action, $args = NULL) {
return apply_filters('plugins_api_result', $res, $action, $args);
}
/**
*
*
* @param unknown_type $args
* @return unknown
*/
function install_popular_tags( $args = array() ) {
if ( ! ($cache = wp_cache_get('popular_tags', 'api')) && ! ($cache = get_option('wporg_popular_tags')) )
add_option('wporg_popular_tags', array(), '', 'no');///No autoload.
add_option('wporg_popular_tags', array(), '', 'no'); ///No autoload.
if ( $cache && $cache->timeout + 3 * 60 * 60 > time() )
return $cache->cached;

View File

@ -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 );
}

View File

@ -1,7 +1,7 @@
<?php
/**
* _wp_translate_postdata() - Rename $_POST data from form names to DB post columns.
* Rename $_POST data from form names to DB post columns.
*
* Manipulates $_POST directly.
*
@ -195,8 +195,8 @@ function get_default_post_to_edit() {
$text = wp_specialchars( stripslashes( urldecode( $_REQUEST['text'] ) ) );
$text = funky_javascript_fix( $text);
$popupurl = clean_url($_REQUEST['popupurl']);
$post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text";
}
$post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\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.

View File

@ -1,6 +1,19 @@
<?php
/**
* WordPress Widgets Administration API
*
* @package WordPress
* @subpackage Administration
*/
// $_search is unsanitized
/**
* Display list of widgets, either all or matching search.
*
* @since unknown
*
* @param unknown_type $show
* @param unknown_type $_search Optional. Search for widgets. Should be unsanitized.
*/
function wp_list_widgets( $show = 'all', $_search = false ) {
global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
if ( $_search ) {
@ -148,8 +161,13 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $sidebar
*/
function wp_list_widget_controls( $sidebar ) {
add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' );
?>
@ -163,7 +181,14 @@ function wp_list_widget_controls( $sidebar ) {
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $params
* @return unknown
*/
function wp_list_widget_controls_dynamic_sidebar( $params ) {
global $wp_registered_widgets;
static $i = 0;
@ -182,8 +207,15 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) {
return $params;
}
/*
* Meta widget used to display the control form for a widget. Called from dynamic_sidebar()
/**
* Meta widget used to display the control form for a widget.
*
* Called from dynamic_sidebar().
*
* @since unknown
*
* @param unknown_type $sidebar_args
* @return unknown
*/
function wp_widget_control( $sidebar_args ) {
global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets, $edit_widget;
@ -276,6 +308,14 @@ function wp_widget_control( $sidebar_args ) {
return $sidebar_args;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $string
* @return unknown
*/
function wp_widget_control_ob_filter( $string ) {
if ( false === $beg = strpos( $string, '%BEG_OF_TITLE%' ) )
return '';