'] = $link_cats; return wp_insert_link($linkdata); } ?>( !is_array($post_id) ) { $post_id = (array) $post_id; $single = true; } $post_id = array_map('intval', $post_id); $post_id = "'" . implode("', '", $post_id) . "'"; $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_N ); if ( empty($pending) ) return 0; if ( $single ) return $pending[0][1]; $pending_keyed = array(); foreach ( $pending as $pend ) $pending_keyed[$pend[0]] = $pend[1]; return $pending_keyed; } // Add avatars to relevant places in admin, or try to function floated_admin_avatar( $name ) { global $comment; $id = $avatar = false; if ( $comment->comment_author_email ) $id = $comment->comment_author_email; if ( $comment->user_id ) $id = $comment->user_id; if ( $id ) $avatar = get_avatar( $id, 32 ); return "$avatar $name"; } if ( is_admin() && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) { if ( get_option('show_avatars') ) add_filter( 'comment_author', 'floated_admin_avatar' ); } ?> or on failure, string Filename on success. */ function download_url( $url ) { //WARNING: The file is not automatically deleted, The script must unlink() the file. if( ! $url ) return new WP_Error('http_no_url', __('Invalid URL Provided')); $tmpfname = tempnam(get_temp_dir(), 'wpupdate'); if( ! $tmpfname ) return new WP_Error('http_no_file', __('Could not create Temporary file')); $handle = @fopen($tmpfname, 'w'); if( ! $handle ) return new WP_Error('http_no_file', __('Could not create Temporary file')); require_once( ABSPATH . 'wp-includes/class-snoopy.php' ); $snoopy = new Snoopy(); $snoopy->fetch($url); if( $snoopy->status != '200' ){ fclose($handle); unlink($tmpfname); return new WP_Error('http_404', trim($snoopy->response_code)); } fwrite($handle, $snoopy->results); fclose($handle); return $tmpfname; } function unzip_file($file, $to) { global $wp_filesystem; if ( ! $wp_filesystem || !is_object($wp_filesystem) ) return new WP_Error('fs_unavailable', __('Could not access filesystem.')); $fs =& $wp_filesystem; require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php'); $archive = new PclZip($file); // Is the archive valid? if ( false == ($archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING)) ) return new WP_Error('incompatible_archive', __('Incompatible archive'), $archive->errorInfo(true)); if ( 0 == count($archive_files) ) return new WP_Error('empty_archive', __('Empty archive')); $to = trailingslashit($to); $path = explode('/', $to); $tmppath = ''; for ( $j = 0; $j < count($path) - 1; $j++ ) { $tmppath .= $path[$j] . '/'; if ( ! $fs->is_dir($tmppath) ) $fs->mkdir($tmppath, 0755); } foreach ($archive_files as $file) { $path = explode('/', $file['filename']); $tmppath = ''; // Loop through each of the items and check that the folder exists. for ( $j = 0; $j < count($path) - 1; $j++ ) { $tmppath .= $path[$j] . '/'; if ( ! $fs->is_dir($to . $tmppath) ) if ( !$fs->mkdir($to . $tmppath, 0755) ) return new WP_Error('mkdir_failed', __('Could not create directory')); } // We've made sure the folders are there, so let's extract the file now: if ( ! $file['folder'] ) if ( !$fs->put_contents( $to . $file['filename'], $file['content']) ) return new WP_Error('copy_failed', __('Could not copy file')); $fs->chmod($to . $file['filename'], 0644); } return true; } function copy_dir($from, $to) { global $wp_filesystem; $dirlist = $wp_filesystem->dirlist($from); $from = trailingslashit($from); $to = trailingslashit($to); foreach ( (array) $dirlist as $filename => $fileinfo ) { if ( 'f' == $fileinfo['type'] ) { if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) ) return false; $wp_filesystem->chmod($to . $filename, 0644); } elseif ( 'd' == $fileinfo['type'] ) { if ( !$wp_filesystem->mkdir($to . $filename, 0755) ) return false; if ( !copy_dir($from . $filename, $to . $filename) ) return false; } } return true; } function WP_Filesystem( $args = false, $preference = false ) { global $wp_filesystem; $method = get_filesystem_method($preference); if ( ! $method ) return false; require_once('class-wp-filesystem-'.$method.'.php'); $method = "WP_Filesystem_$method"; $wp_filesystem = new $method($args); if ( $wp_filesystem->errors->get_error_code() ) return false; if ( !$wp_filesystem->connect() ) return false; //There was an erorr connecting to the server. return true; } function get_filesystem_method() { $tempFile = tempnam(get_temp_dir(), 'WPU'); if ( getmyuid() == fileowner($tempFile) ) { unlink($tempFile); return 'direct'; } else { unlink($tempFile); } if ( extension_loaded('ftp') ) return 'ftpext'; if ( extension_loaded('sockets') || function_exists('fsockopen') ) return 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread return false; } ?> on wp_exif_frac2dec($str) { @list( $n, $d ) = explode( '/', $str ); if ( !empty($d) ) return $n / $d; return $str; } // convert the exif date format to a unix timestamp 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 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. $meta = array( 'aperture' => 0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '', ); // 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']) ) { $iptc = iptcparse($info['APP13']); if ( !empty($iptc['2#110'][0]) ) // credit $meta['credit'] = trim( $iptc['2#110'][0] ); elseif ( !empty($iptc['2#080'][0]) ) // byline $meta['credit'] = trim( $iptc['2#080'][0] ); if ( !empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0]) ) // created datee and time $meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]); if ( !empty($iptc['2#120'][0]) ) // caption $meta['caption'] = trim( $iptc['2#120'][0] ); if ( !empty($iptc['2#116'][0]) ) // copyright $meta['copyright'] = trim( $iptc['2#116'][0] ); if ( !empty($iptc['2#005'][0]) ) // title $meta['title'] = trim( $iptc['2#005'][0] ); } } // fetch additional info from exif if available if ( is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)) ) ) { $exif = @exif_read_data( $file ); if (!empty($exif['FNumber'])) $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 ); if (!empty($exif['Model'])) $meta['camera'] = trim( $exif['Model'] ); if (!empty($exif['DateTimeDigitized'])) $meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']); if (!empty($exif['FocalLength'])) $meta['focal_length'] = wp_exif_frac2dec( $exif['FocalLength'] ); if (!empty($exif['ISOSpeedRatings'])) $meta['iso'] = $exif['ISOSpeedRatings']; if (!empty($exif['ExposureTime'])) $meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] ); } // FIXME: try other exif libraries if available return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType ); } // is the file a real image file? function file_is_valid_image($path) { $size = @getimagesize($path); return !empty($size); } // is the file an image suitable for displaying within a web page? function file_is_displayable_image($path) { $info = @getimagesize($path); if ( empty($info) ) $result = false; elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) ) // only gif, jpeg and png images can reliably be displayed $result = false; elseif ( $info['channels'] > 0 && $info['channels'] != 3 ) { // some web browsers can't display cmyk or grayscale jpegs $result = false; } else $result = true; return apply_filters('file_is_displayable_image', $result, $path); } ?> ( $object, $file ); return array( 'file' => $file, 'id' => $id ); } ?> y[3]; return $menu_array[3]; } } else { $title = $menu_array[0]; return $title; } } } else { foreach (array_keys( $submenu ) as $parent) { foreach ( $submenu[$parent] as $submenu_array ) { if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) && (($parent == $pagenow ) || ($parent == $plugin_page ) || ($plugin_page == $hook ) || (($pagenow == 'admin.php' ) && ($parent1 != $submenu_array[2] ) ) ) ) { $title = $submenu_array[3]; return $submenu_array[3]; } if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page continue; if ( isset( $submenu_array[3] ) ) { $title = $submenu_array[3]; return $submenu_array[3]; } else { $title = $submenu_array[0]; return $title; } } } } return $title; } function get_plugin_page_hook( $plugin_page, $parent_page ) { $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); if ( has_action($hook) ) return $hook; else return null; } function get_plugin_page_hookname( $plugin_page, $parent_page ) { global $admin_page_hooks; $parent = get_admin_page_parent(); if ( empty ( $parent_page ) || 'admin.php' == $parent_page ) { if ( isset( $admin_page_hooks[$plugin_page] )) $page_type = 'toplevel'; else if ( isset( $admin_page_hooks[$parent] )) $page_type = $admin_page_hooks[$parent]; } else if ( isset( $admin_page_hooks[$parent_page] ) ) { $page_type = $admin_page_hooks[$parent_page]; } else { $page_type = 'admin'; } $plugin_name = preg_replace( '!\.php!', '', $plugin_page ); return $page_type.'_page_'.$plugin_name; } function user_can_access_admin_page() { global $pagenow; global $menu; global $submenu; global $_wp_menu_nopriv; global $_wp_submenu_nopriv; global $plugin_page; $parent = get_admin_page_parent(); if ( isset( $_wp_submenu_nopriv[$parent][$pagenow] ) ) return false; if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) return false; if ( empty( $parent) ) { if ( isset( $_wp_menu_nopriv[$pagenow] ) ) return false; if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) ) return false; if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) return false; foreach (array_keys( $_wp_submenu_nopriv ) as $key ) { if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) ) return false; if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) return false; } return true; } if ( isset( $submenu[$parent] ) ) { foreach ( $submenu[$parent] as $submenu_array ) { if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) { if ( current_user_can( $submenu_array[1] )) return true; else return false; } else if ( $submenu_array[2] == $pagenow ) { if ( current_user_can( $submenu_array[1] )) return true; else return false; } } } foreach ( $menu as $menu_array ) { if ( $menu_array[2] == $parent) { if ( current_user_can( $menu_array[1] )) return true; else return false; } } return true; } ?> ID ) { $post = & get_post( $post_ID, ARRAY_A ); $search = "#]+rel=('|\")[^'\"]*attachment[^>]*>#ie"; // See if we have any rel="attachment" links if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) ) return; $i = 0; $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i"; foreach ( $anchor_matches[0] as $anchor ) { if ( 0 == preg_match( $search, $anchor, $id_matches ) ) continue; $id = (int) $id_matches[3]; // While we have the attachment ID, let's adopt any orphans. $attachment = & get_post( $id, ARRAY_A ); if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) { $attachment['post_parent'] = $post_ID; // Escape data pulled from DB. $attachment = add_magic_quotes( $attachment); wp_update_post( $attachment); } $post_search[$i] = $anchor; $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor ); ++$i; } $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] ); // Escape data pulled from DB. $post = add_magic_quotes( $post); return wp_update_post( $post); } // Move child posts to a new parent function _relocate_children( $old_ID, $new_ID ) { global $wpdb; $old_ID = (int) $old_ID; $new_ID = (int) $new_ID; return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" ); } function get_available_post_statuses($type = 'post') { $stati = wp_count_posts($type); return array_keys(get_object_vars($stati)); } function wp_edit_posts_query( $q = false ) { global $wpdb; if ( false === $q ) $q = $_GET; $q['m'] = (int) $q['m']; $q['cat'] = (int) $q['cat']; $post_stati = array( // array( adj, noun ) 'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')), 'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')), 'pending' => array(__('Pending Review'), __('Pending posts'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')), 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')), 'private' => array(__('Private'), __('Private posts'), __ngettext_noop('Private (%s)', 'Private (%s)')), ); $post_stati = apply_filters('post_stati', $post_stati); $avail_post_stati = get_available_post_statuses('post'); $post_status_q = ''; if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) { $post_status_q = '&post_status=' . $q['post_status']; $post_status_q .= '&perm=readable'; } if ( 'pending' === $q['post_status'] ) { $order = 'ASC'; $orderby = 'modified'; } elseif ( 'draft' === $q['post_status'] ) { $order = 'DESC'; $orderby = 'modified'; } else { $order = 'DESC'; $orderby = 'date'; } wp("post_type=post&what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby"); return array($post_stati, $avail_post_stati); } function get_available_post_mime_types($type = 'attachment') { global $wpdb; $types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type)); return $types; } function wp_edit_attachments_query( $q = false ) { global $wpdb; if ( false === $q ) $q = $_GET; $q['m'] = (int) $q['m']; $q['cat'] = (int) $q['cat']; $q['post_type'] = 'attachment'; $q['post_status'] = 'any'; $q['posts_per_page'] = 15; $post_mime_types = array( // array( adj, noun ) 'image' => array(__('Images'), __('Manage Images'), __ngettext_noop('Image (%s)', 'Images (%s)')), 'audio' => array(__('Audio'), __('Manage Audio'), __ngettext_noop('Audio (%s)', 'Audio (%s)')), 'video' => array(__('Video'), __('Manage Video'), __ngettext_noop('Video (%s)', 'Video (%s)')), ); $post_mime_types = apply_filters('post_mime_types', $post_mime_types); $avail_post_mime_types = get_available_post_mime_types('attachment'); if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) unset($q['post_mime_type']); wp($q); return array($post_mime_types, $avail_post_mime_types); } function postbox_classes( $id, $page ) { $current_user = wp_get_current_user(); if ( $closed = get_usermeta( $current_user->ID, 'closedpostboxes_'.$page ) ) { if ( !is_array( $closed ) ) return ''; return in_array( $id, $closed )? 'if-js-closed' : ''; } else { if ( 'tagsdiv' == $id || 'categorydiv' == $id ) return ''; else return 'if-js-closed'; } } function get_sample_permalink($id, $title=null, $name = null) { $post = &get_post($id); if (!$post->ID) { return array('', ''); } $original_status = $post->post_status; $original_date = $post->post_date; $original_name = $post->post_name; // Hack: get_permalink would return ugly permalink for // drafts, so we will fake, that our post is published if (in_array($post->post_status, array('draft', 'pending'))) { $post->post_status = 'publish'; $post->post_date = date('Y-m-d H:i:s'); $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID); } // If the user wants to set a new name -- override the current one // Note: if empty name is supplied -- use the title instead, see #6072 if (!is_null($name)) { $post->post_name = sanitize_title($name? $name : $title, $post->ID); } $permalink = get_permalink($post, true); // Handle page hierarchy if ( 'page' == $post->post_type ) { $uri = get_page_uri($post->ID); $uri = untrailingslashit($uri); $uri = strrev( stristr( strrev( $uri ), '/' ) ); $uri = untrailingslashit($uri); if ( !empty($uri) ) $uri .='/'; $permalink = str_replace('%pagename%', "${uri}%pagename%", $permalink); } $permalink = array($permalink, $post->post_name); $post->post_status = $original_status; $post->post_date = $original_date; $post->post_name = $original_name; $post->post_title = $original_title; return $permalink; } function get_sample_permalink_html($id, $new_title=null, $new_slug=null) { $post = &get_post($id); list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); if (false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%')) { return ''; } $title = __('Click to edit this part of the permalink'); if (strlen($post_name) > 30) { $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14); } else { $post_name_abridged = $post_name; } $post_name_html = ''.$post_name_abridged.''.$post_name.''; $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); $return = '' . __('Permalink:') . "\n" . '' . $display_link . "\n"; $return .= '' . __('Edit') . "\n"; return $return; } // false: not locked or locked by current user // int: user ID of user with lock function wp_check_post_lock( $post_id ) { global $current_user; if ( !$post = get_post( $post_id ) ) return false; $lock = get_post_meta( $post->ID, '_edit_lock', true ); $last = get_post_meta( $post->ID, '_edit_last', true ); $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ); if ( $lock && $lock > time() - $time_window && $last != $current_user->ID ) return $last; return false; } function wp_set_post_lock( $post_id ) { global $current_user; if ( !$post = get_post( $post_id ) ) return false; if ( !$current_user || !$current_user->ID ) return false; $now = time(); if ( !add_post_meta( $post->ID, '_edit_lock', $now, true ) ) update_post_meta( $post->ID, '_edit_lock', $now ); if ( !add_post_meta( $post->ID, '_edit_last', $current_user->ID, true ) ) update_post_meta( $post->ID, '_edit_last', $current_user->ID ); } ?> _edit = join( ', ', $tag_names ); $tags_to_edit = attribute_escape( $tags_to_edit ); $tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit ); return $tags_to_edit; } function tag_exists($tag_name) { return is_term($tag_name, 'post_tag'); } function wp_create_tag($tag_name) { if ( $id = tag_exists($tag_name) ) return $id; return wp_insert_term($tag_name, 'post_tag'); } ?>
Fatal error: Cannot redeclare documentation_link() (previously declared in /home/content/u/m/p/umpqua/html/moth/wp-includes/deprecated.php:1272) in /home/content/u/m/p/umpqua/html/moth/wp-admin/includes/template.php on line 72