Edit File by line
/home/zeestwma/redstone.../wp-inclu...
File: functions.php
}
[500] Fix | Delete
[501] Fix | Delete
/**
[502] Fix | Delete
* Converts a duration to human readable format.
[503] Fix | Delete
*
[504] Fix | Delete
* @since 5.1.0
[505] Fix | Delete
*
[506] Fix | Delete
* @param string $duration Duration will be in string format (HH:ii:ss) OR (ii:ss),
[507] Fix | Delete
* with a possible prepended negative sign (-).
[508] Fix | Delete
* @return string|false A human readable duration string, false on failure.
[509] Fix | Delete
*/
[510] Fix | Delete
function human_readable_duration( $duration = '' ) {
[511] Fix | Delete
if ( ( empty( $duration ) || ! is_string( $duration ) ) ) {
[512] Fix | Delete
return false;
[513] Fix | Delete
}
[514] Fix | Delete
[515] Fix | Delete
$duration = trim( $duration );
[516] Fix | Delete
[517] Fix | Delete
// Remove prepended negative sign.
[518] Fix | Delete
if ( str_starts_with( $duration, '-' ) ) {
[519] Fix | Delete
$duration = substr( $duration, 1 );
[520] Fix | Delete
}
[521] Fix | Delete
[522] Fix | Delete
// Extract duration parts.
[523] Fix | Delete
$duration_parts = array_reverse( explode( ':', $duration ) );
[524] Fix | Delete
$duration_count = count( $duration_parts );
[525] Fix | Delete
[526] Fix | Delete
$hour = null;
[527] Fix | Delete
$minute = null;
[528] Fix | Delete
$second = null;
[529] Fix | Delete
[530] Fix | Delete
if ( 3 === $duration_count ) {
[531] Fix | Delete
// Validate HH:ii:ss duration format.
[532] Fix | Delete
if ( ! ( (bool) preg_match( '/^([0-9]+):([0-5]?[0-9]):([0-5]?[0-9])$/', $duration ) ) ) {
[533] Fix | Delete
return false;
[534] Fix | Delete
}
[535] Fix | Delete
// Three parts: hours, minutes & seconds.
[536] Fix | Delete
list( $second, $minute, $hour ) = $duration_parts;
[537] Fix | Delete
} elseif ( 2 === $duration_count ) {
[538] Fix | Delete
// Validate ii:ss duration format.
[539] Fix | Delete
if ( ! ( (bool) preg_match( '/^([0-5]?[0-9]):([0-5]?[0-9])$/', $duration ) ) ) {
[540] Fix | Delete
return false;
[541] Fix | Delete
}
[542] Fix | Delete
// Two parts: minutes & seconds.
[543] Fix | Delete
list( $second, $minute ) = $duration_parts;
[544] Fix | Delete
} else {
[545] Fix | Delete
return false;
[546] Fix | Delete
}
[547] Fix | Delete
[548] Fix | Delete
$human_readable_duration = array();
[549] Fix | Delete
[550] Fix | Delete
// Add the hour part to the string.
[551] Fix | Delete
if ( is_numeric( $hour ) ) {
[552] Fix | Delete
/* translators: %s: Time duration in hour or hours. */
[553] Fix | Delete
$human_readable_duration[] = sprintf( _n( '%s hour', '%s hours', $hour ), (int) $hour );
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
// Add the minute part to the string.
[557] Fix | Delete
if ( is_numeric( $minute ) ) {
[558] Fix | Delete
/* translators: %s: Time duration in minute or minutes. */
[559] Fix | Delete
$human_readable_duration[] = sprintf( _n( '%s minute', '%s minutes', $minute ), (int) $minute );
[560] Fix | Delete
}
[561] Fix | Delete
[562] Fix | Delete
// Add the second part to the string.
[563] Fix | Delete
if ( is_numeric( $second ) ) {
[564] Fix | Delete
/* translators: %s: Time duration in second or seconds. */
[565] Fix | Delete
$human_readable_duration[] = sprintf( _n( '%s second', '%s seconds', $second ), (int) $second );
[566] Fix | Delete
}
[567] Fix | Delete
[568] Fix | Delete
return implode( ', ', $human_readable_duration );
[569] Fix | Delete
}
[570] Fix | Delete
[571] Fix | Delete
/**
[572] Fix | Delete
* Gets the week start and end from the datetime or date string from MySQL.
[573] Fix | Delete
*
[574] Fix | Delete
* @since 0.71
[575] Fix | Delete
*
[576] Fix | Delete
* @param string $mysqlstring Date or datetime field type from MySQL.
[577] Fix | Delete
* @param int|string $start_of_week Optional. Start of the week as an integer. Default empty string.
[578] Fix | Delete
* @return int[] {
[579] Fix | Delete
* Week start and end dates as Unix timestamps.
[580] Fix | Delete
*
[581] Fix | Delete
* @type int $start The week start date as a Unix timestamp.
[582] Fix | Delete
* @type int $end The week end date as a Unix timestamp.
[583] Fix | Delete
* }
[584] Fix | Delete
*/
[585] Fix | Delete
function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
[586] Fix | Delete
// MySQL string year.
[587] Fix | Delete
$my = substr( $mysqlstring, 0, 4 );
[588] Fix | Delete
[589] Fix | Delete
// MySQL string month.
[590] Fix | Delete
$mm = substr( $mysqlstring, 8, 2 );
[591] Fix | Delete
[592] Fix | Delete
// MySQL string day.
[593] Fix | Delete
$md = substr( $mysqlstring, 5, 2 );
[594] Fix | Delete
[595] Fix | Delete
// The timestamp for MySQL string day.
[596] Fix | Delete
$day = mktime( 0, 0, 0, $md, $mm, $my );
[597] Fix | Delete
[598] Fix | Delete
// The day of the week from the timestamp.
[599] Fix | Delete
$weekday = (int) gmdate( 'w', $day );
[600] Fix | Delete
[601] Fix | Delete
if ( ! is_numeric( $start_of_week ) ) {
[602] Fix | Delete
$start_of_week = (int) get_option( 'start_of_week' );
[603] Fix | Delete
}
[604] Fix | Delete
[605] Fix | Delete
if ( $weekday < $start_of_week ) {
[606] Fix | Delete
$weekday += 7;
[607] Fix | Delete
}
[608] Fix | Delete
[609] Fix | Delete
// The most recent week start day on or before $day.
[610] Fix | Delete
$start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week );
[611] Fix | Delete
[612] Fix | Delete
// $start + 1 week - 1 second.
[613] Fix | Delete
$end = $start + WEEK_IN_SECONDS - 1;
[614] Fix | Delete
[615] Fix | Delete
return compact( 'start', 'end' );
[616] Fix | Delete
}
[617] Fix | Delete
[618] Fix | Delete
/**
[619] Fix | Delete
* Serializes data, if needed.
[620] Fix | Delete
*
[621] Fix | Delete
* @since 2.0.5
[622] Fix | Delete
*
[623] Fix | Delete
* @param string|array|object $data Data that might be serialized.
[624] Fix | Delete
* @return mixed A scalar data.
[625] Fix | Delete
*/
[626] Fix | Delete
function maybe_serialize( $data ) {
[627] Fix | Delete
if ( is_array( $data ) || is_object( $data ) ) {
[628] Fix | Delete
return serialize( $data );
[629] Fix | Delete
}
[630] Fix | Delete
[631] Fix | Delete
/*
[632] Fix | Delete
* Double serialization is required for backward compatibility.
[633] Fix | Delete
* See https://core.trac.wordpress.org/ticket/12930
[634] Fix | Delete
* Also the world will end. See WP 3.6.1.
[635] Fix | Delete
*/
[636] Fix | Delete
if ( is_serialized( $data, false ) ) {
[637] Fix | Delete
return serialize( $data );
[638] Fix | Delete
}
[639] Fix | Delete
[640] Fix | Delete
return $data;
[641] Fix | Delete
}
[642] Fix | Delete
[643] Fix | Delete
/**
[644] Fix | Delete
* Unserializes data only if it was serialized.
[645] Fix | Delete
*
[646] Fix | Delete
* @since 2.0.0
[647] Fix | Delete
*
[648] Fix | Delete
* @param string $data Data that might be unserialized.
[649] Fix | Delete
* @return mixed Unserialized data can be any type.
[650] Fix | Delete
*/
[651] Fix | Delete
function maybe_unserialize( $data ) {
[652] Fix | Delete
if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in.
[653] Fix | Delete
return @unserialize( trim( $data ) );
[654] Fix | Delete
}
[655] Fix | Delete
[656] Fix | Delete
return $data;
[657] Fix | Delete
}
[658] Fix | Delete
[659] Fix | Delete
/**
[660] Fix | Delete
* Checks value to find if it was serialized.
[661] Fix | Delete
*
[662] Fix | Delete
* If $data is not a string, then returned value will always be false.
[663] Fix | Delete
* Serialized data is always a string.
[664] Fix | Delete
*
[665] Fix | Delete
* @since 2.0.5
[666] Fix | Delete
* @since 6.1.0 Added Enum support.
[667] Fix | Delete
*
[668] Fix | Delete
* @param string $data Value to check to see if was serialized.
[669] Fix | Delete
* @param bool $strict Optional. Whether to be strict about the end of the string. Default true.
[670] Fix | Delete
* @return bool False if not serialized and true if it was.
[671] Fix | Delete
*/
[672] Fix | Delete
function is_serialized( $data, $strict = true ) {
[673] Fix | Delete
// If it isn't a string, it isn't serialized.
[674] Fix | Delete
if ( ! is_string( $data ) ) {
[675] Fix | Delete
return false;
[676] Fix | Delete
}
[677] Fix | Delete
$data = trim( $data );
[678] Fix | Delete
if ( 'N;' === $data ) {
[679] Fix | Delete
return true;
[680] Fix | Delete
}
[681] Fix | Delete
if ( strlen( $data ) < 4 ) {
[682] Fix | Delete
return false;
[683] Fix | Delete
}
[684] Fix | Delete
if ( ':' !== $data[1] ) {
[685] Fix | Delete
return false;
[686] Fix | Delete
}
[687] Fix | Delete
if ( $strict ) {
[688] Fix | Delete
$lastc = substr( $data, -1 );
[689] Fix | Delete
if ( ';' !== $lastc && '}' !== $lastc ) {
[690] Fix | Delete
return false;
[691] Fix | Delete
}
[692] Fix | Delete
} else {
[693] Fix | Delete
$semicolon = strpos( $data, ';' );
[694] Fix | Delete
$brace = strpos( $data, '}' );
[695] Fix | Delete
// Either ; or } must exist.
[696] Fix | Delete
if ( false === $semicolon && false === $brace ) {
[697] Fix | Delete
return false;
[698] Fix | Delete
}
[699] Fix | Delete
// But neither must be in the first X characters.
[700] Fix | Delete
if ( false !== $semicolon && $semicolon < 3 ) {
[701] Fix | Delete
return false;
[702] Fix | Delete
}
[703] Fix | Delete
if ( false !== $brace && $brace < 4 ) {
[704] Fix | Delete
return false;
[705] Fix | Delete
}
[706] Fix | Delete
}
[707] Fix | Delete
$token = $data[0];
[708] Fix | Delete
switch ( $token ) {
[709] Fix | Delete
case 's':
[710] Fix | Delete
if ( $strict ) {
[711] Fix | Delete
if ( '"' !== substr( $data, -2, 1 ) ) {
[712] Fix | Delete
return false;
[713] Fix | Delete
}
[714] Fix | Delete
} elseif ( ! str_contains( $data, '"' ) ) {
[715] Fix | Delete
return false;
[716] Fix | Delete
}
[717] Fix | Delete
// Or else fall through.
[718] Fix | Delete
case 'a':
[719] Fix | Delete
case 'O':
[720] Fix | Delete
case 'E':
[721] Fix | Delete
return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
[722] Fix | Delete
case 'b':
[723] Fix | Delete
case 'i':
[724] Fix | Delete
case 'd':
[725] Fix | Delete
$end = $strict ? '$' : '';
[726] Fix | Delete
return (bool) preg_match( "/^{$token}:[0-9.E+-]+;$end/", $data );
[727] Fix | Delete
}
[728] Fix | Delete
return false;
[729] Fix | Delete
}
[730] Fix | Delete
[731] Fix | Delete
/**
[732] Fix | Delete
* Checks whether serialized data is of string type.
[733] Fix | Delete
*
[734] Fix | Delete
* @since 2.0.5
[735] Fix | Delete
*
[736] Fix | Delete
* @param string $data Serialized data.
[737] Fix | Delete
* @return bool False if not a serialized string, true if it is.
[738] Fix | Delete
*/
[739] Fix | Delete
function is_serialized_string( $data ) {
[740] Fix | Delete
// if it isn't a string, it isn't a serialized string.
[741] Fix | Delete
if ( ! is_string( $data ) ) {
[742] Fix | Delete
return false;
[743] Fix | Delete
}
[744] Fix | Delete
$data = trim( $data );
[745] Fix | Delete
if ( strlen( $data ) < 4 ) {
[746] Fix | Delete
return false;
[747] Fix | Delete
} elseif ( ':' !== $data[1] ) {
[748] Fix | Delete
return false;
[749] Fix | Delete
} elseif ( ! str_ends_with( $data, ';' ) ) {
[750] Fix | Delete
return false;
[751] Fix | Delete
} elseif ( 's' !== $data[0] ) {
[752] Fix | Delete
return false;
[753] Fix | Delete
} elseif ( '"' !== substr( $data, -2, 1 ) ) {
[754] Fix | Delete
return false;
[755] Fix | Delete
} else {
[756] Fix | Delete
return true;
[757] Fix | Delete
}
[758] Fix | Delete
}
[759] Fix | Delete
[760] Fix | Delete
/**
[761] Fix | Delete
* Retrieves post title from XML-RPC XML.
[762] Fix | Delete
*
[763] Fix | Delete
* If the `title` element is not found in the XML, the default post title
[764] Fix | Delete
* from the `$post_default_title` global will be used instead.
[765] Fix | Delete
*
[766] Fix | Delete
* @since 0.71
[767] Fix | Delete
*
[768] Fix | Delete
* @global string $post_default_title Default XML-RPC post title.
[769] Fix | Delete
*
[770] Fix | Delete
* @param string $content XML-RPC XML Request content.
[771] Fix | Delete
* @return string Post title.
[772] Fix | Delete
*/
[773] Fix | Delete
function xmlrpc_getposttitle( $content ) {
[774] Fix | Delete
global $post_default_title;
[775] Fix | Delete
if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) {
[776] Fix | Delete
$post_title = $matchtitle[1];
[777] Fix | Delete
} else {
[778] Fix | Delete
$post_title = $post_default_title;
[779] Fix | Delete
}
[780] Fix | Delete
return $post_title;
[781] Fix | Delete
}
[782] Fix | Delete
[783] Fix | Delete
/**
[784] Fix | Delete
* Retrieves the post category or categories from XML-RPC XML.
[785] Fix | Delete
*
[786] Fix | Delete
* If the `category` element is not found in the XML, the default post category
[787] Fix | Delete
* from the `$post_default_category` global will be used instead.
[788] Fix | Delete
* The return type will then be a string.
[789] Fix | Delete
*
[790] Fix | Delete
* If the `category` element is found, the return type will be an array.
[791] Fix | Delete
*
[792] Fix | Delete
* @since 0.71
[793] Fix | Delete
*
[794] Fix | Delete
* @global string $post_default_category Default XML-RPC post category.
[795] Fix | Delete
*
[796] Fix | Delete
* @param string $content XML-RPC XML Request content.
[797] Fix | Delete
* @return string[]|string An array of category names or default category name.
[798] Fix | Delete
*/
[799] Fix | Delete
function xmlrpc_getpostcategory( $content ) {
[800] Fix | Delete
global $post_default_category;
[801] Fix | Delete
if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) {
[802] Fix | Delete
$post_category = trim( $matchcat[1], ',' );
[803] Fix | Delete
$post_category = explode( ',', $post_category );
[804] Fix | Delete
} else {
[805] Fix | Delete
$post_category = $post_default_category;
[806] Fix | Delete
}
[807] Fix | Delete
return $post_category;
[808] Fix | Delete
}
[809] Fix | Delete
[810] Fix | Delete
/**
[811] Fix | Delete
* XML-RPC XML content without title and category elements.
[812] Fix | Delete
*
[813] Fix | Delete
* @since 0.71
[814] Fix | Delete
*
[815] Fix | Delete
* @param string $content XML-RPC XML Request content.
[816] Fix | Delete
* @return string XML-RPC XML Request content without title and category elements.
[817] Fix | Delete
*/
[818] Fix | Delete
function xmlrpc_removepostdata( $content ) {
[819] Fix | Delete
$content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content );
[820] Fix | Delete
$content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content );
[821] Fix | Delete
$content = trim( $content );
[822] Fix | Delete
return $content;
[823] Fix | Delete
}
[824] Fix | Delete
[825] Fix | Delete
/**
[826] Fix | Delete
* Uses RegEx to extract URLs from arbitrary content.
[827] Fix | Delete
*
[828] Fix | Delete
* @since 3.7.0
[829] Fix | Delete
* @since 6.0.0 Fixes support for HTML entities (Trac 30580).
[830] Fix | Delete
*
[831] Fix | Delete
* @param string $content Content to extract URLs from.
[832] Fix | Delete
* @return string[] Array of URLs found in passed string.
[833] Fix | Delete
*/
[834] Fix | Delete
function wp_extract_urls( $content ) {
[835] Fix | Delete
preg_match_all(
[836] Fix | Delete
"#([\"']?)("
[837] Fix | Delete
. '(?:([\w-]+:)?//?)'
[838] Fix | Delete
. '[^\s()<>]+'
[839] Fix | Delete
. '[.]'
[840] Fix | Delete
. '(?:'
[841] Fix | Delete
. '\([\w\d]+\)|'
[842] Fix | Delete
. '(?:'
[843] Fix | Delete
. "[^`!()\[\]{}:'\".,<>«»“”‘’\s]|"
[844] Fix | Delete
. '(?:[:]\d+)?/?'
[845] Fix | Delete
. ')+'
[846] Fix | Delete
. ')'
[847] Fix | Delete
. ")\\1#",
[848] Fix | Delete
$content,
[849] Fix | Delete
$post_links
[850] Fix | Delete
);
[851] Fix | Delete
[852] Fix | Delete
$post_links = array_unique(
[853] Fix | Delete
array_map(
[854] Fix | Delete
static function ( $link ) {
[855] Fix | Delete
// Decode to replace valid entities, like &amp;.
[856] Fix | Delete
$link = html_entity_decode( $link );
[857] Fix | Delete
// Maintain backward compatibility by removing extraneous semi-colons (`;`).
[858] Fix | Delete
return str_replace( ';', '', $link );
[859] Fix | Delete
},
[860] Fix | Delete
$post_links[2]
[861] Fix | Delete
)
[862] Fix | Delete
);
[863] Fix | Delete
[864] Fix | Delete
return array_values( $post_links );
[865] Fix | Delete
}
[866] Fix | Delete
[867] Fix | Delete
/**
[868] Fix | Delete
* Checks content for video and audio links to add as enclosures.
[869] Fix | Delete
*
[870] Fix | Delete
* Will not add enclosures that have already been added and will
[871] Fix | Delete
* remove enclosures that are no longer in the post. This is called as
[872] Fix | Delete
* pingbacks and trackbacks.
[873] Fix | Delete
*
[874] Fix | Delete
* @since 1.5.0
[875] Fix | Delete
* @since 5.3.0 The `$content` parameter was made optional, and the `$post` parameter was
[876] Fix | Delete
* updated to accept a post ID or a WP_Post object.
[877] Fix | Delete
* @since 5.6.0 The `$content` parameter is no longer optional, but passing `null` to skip it
[878] Fix | Delete
* is still supported.
[879] Fix | Delete
*
[880] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[881] Fix | Delete
*
[882] Fix | Delete
* @param string|null $content Post content. If `null`, the `post_content` field from `$post` is used.
[883] Fix | Delete
* @param int|WP_Post $post Post ID or post object.
[884] Fix | Delete
* @return void|false Void on success, false if the post is not found.
[885] Fix | Delete
*/
[886] Fix | Delete
function do_enclose( $content, $post ) {
[887] Fix | Delete
global $wpdb;
[888] Fix | Delete
[889] Fix | Delete
// @todo Tidy this code and make the debug code optional.
[890] Fix | Delete
require_once ABSPATH . WPINC . '/class-IXR.php';
[891] Fix | Delete
[892] Fix | Delete
$post = get_post( $post );
[893] Fix | Delete
if ( ! $post ) {
[894] Fix | Delete
return false;
[895] Fix | Delete
}
[896] Fix | Delete
[897] Fix | Delete
if ( null === $content ) {
[898] Fix | Delete
$content = $post->post_content;
[899] Fix | Delete
}
[900] Fix | Delete
[901] Fix | Delete
$post_links = array();
[902] Fix | Delete
[903] Fix | Delete
$pung = get_enclosed( $post->ID );
[904] Fix | Delete
[905] Fix | Delete
$post_links_temp = wp_extract_urls( $content );
[906] Fix | Delete
[907] Fix | Delete
foreach ( $pung as $link_test ) {
[908] Fix | Delete
// Link is no longer in post.
[909] Fix | Delete
if ( ! in_array( $link_test, $post_links_temp, true ) ) {
[910] Fix | Delete
$mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $link_test ) . '%' ) );
[911] Fix | Delete
foreach ( $mids as $mid ) {
[912] Fix | Delete
delete_metadata_by_mid( 'post', $mid );
[913] Fix | Delete
}
[914] Fix | Delete
}
[915] Fix | Delete
}
[916] Fix | Delete
[917] Fix | Delete
foreach ( (array) $post_links_temp as $link_test ) {
[918] Fix | Delete
// If we haven't pung it already.
[919] Fix | Delete
if ( ! in_array( $link_test, $pung, true ) ) {
[920] Fix | Delete
$test = parse_url( $link_test );
[921] Fix | Delete
if ( false === $test ) {
[922] Fix | Delete
continue;
[923] Fix | Delete
}
[924] Fix | Delete
if ( isset( $test['query'] ) ) {
[925] Fix | Delete
$post_links[] = $link_test;
[926] Fix | Delete
} elseif ( isset( $test['path'] ) && ( '/' !== $test['path'] ) && ( '' !== $test['path'] ) ) {
[927] Fix | Delete
$post_links[] = $link_test;
[928] Fix | Delete
}
[929] Fix | Delete
}
[930] Fix | Delete
}
[931] Fix | Delete
[932] Fix | Delete
/**
[933] Fix | Delete
* Filters the list of enclosure links before querying the database.
[934] Fix | Delete
*
[935] Fix | Delete
* Allows for the addition and/or removal of potential enclosures to save
[936] Fix | Delete
* to postmeta before checking the database for existing enclosures.
[937] Fix | Delete
*
[938] Fix | Delete
* @since 4.4.0
[939] Fix | Delete
*
[940] Fix | Delete
* @param string[] $post_links An array of enclosure links.
[941] Fix | Delete
* @param int $post_id Post ID.
[942] Fix | Delete
*/
[943] Fix | Delete
$post_links = apply_filters( 'enclosure_links', $post_links, $post->ID );
[944] Fix | Delete
[945] Fix | Delete
foreach ( (array) $post_links as $url ) {
[946] Fix | Delete
$url = strip_fragment_from_url( $url );
[947] Fix | Delete
[948] Fix | Delete
if ( '' !== $url && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $url ) . '%' ) ) ) {
[949] Fix | Delete
[950] Fix | Delete
$headers = wp_get_http_headers( $url );
[951] Fix | Delete
if ( $headers ) {
[952] Fix | Delete
$len = isset( $headers['Content-Length'] ) ? (int) $headers['Content-Length'] : 0;
[953] Fix | Delete
$type = isset( $headers['Content-Type'] ) ? $headers['Content-Type'] : '';
[954] Fix | Delete
$allowed_types = array( 'video', 'audio' );
[955] Fix | Delete
[956] Fix | Delete
// Check to see if we can figure out the mime type from the extension.
[957] Fix | Delete
$url_parts = parse_url( $url );
[958] Fix | Delete
if ( false !== $url_parts && ! empty( $url_parts['path'] ) ) {
[959] Fix | Delete
$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
[960] Fix | Delete
if ( ! empty( $extension ) ) {
[961] Fix | Delete
foreach ( wp_get_mime_types() as $exts => $mime ) {
[962] Fix | Delete
if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
[963] Fix | Delete
$type = $mime;
[964] Fix | Delete
break;
[965] Fix | Delete
}
[966] Fix | Delete
}
[967] Fix | Delete
}
[968] Fix | Delete
}
[969] Fix | Delete
[970] Fix | Delete
if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types, true ) ) {
[971] Fix | Delete
add_post_meta( $post->ID, 'enclosure', "$url\n$len\n$mime\n" );
[972] Fix | Delete
}
[973] Fix | Delete
}
[974] Fix | Delete
}
[975] Fix | Delete
}
[976] Fix | Delete
}
[977] Fix | Delete
[978] Fix | Delete
/**
[979] Fix | Delete
* Retrieves HTTP Headers from URL.
[980] Fix | Delete
*
[981] Fix | Delete
* @since 1.5.1
[982] Fix | Delete
*
[983] Fix | Delete
* @param string $url URL to retrieve HTTP headers from.
[984] Fix | Delete
* @param bool $deprecated Not Used.
[985] Fix | Delete
* @return \WpOrg\Requests\Utility\CaseInsensitiveDictionary|false Headers on success, false on failure.
[986] Fix | Delete
*/
[987] Fix | Delete
function wp_get_http_headers( $url, $deprecated = false ) {
[988] Fix | Delete
if ( ! empty( $deprecated ) ) {
[989] Fix | Delete
_deprecated_argument( __FUNCTION__, '2.7.0' );
[990] Fix | Delete
}
[991] Fix | Delete
[992] Fix | Delete
$response = wp_safe_remote_head( $url );
[993] Fix | Delete
[994] Fix | Delete
if ( is_wp_error( $response ) ) {
[995] Fix | Delete
return false;
[996] Fix | Delete
}
[997] Fix | Delete
[998] Fix | Delete
return wp_remote_retrieve_headers( $response );
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function