function heydays__add_share_button() { ?> <iframe src="http://www.facebook.com/plugins/like.php ?href=<?php echo get_permalink(); ?> &layout=standard &show-faces=true &width=450 &action=recommend &font=arial &share=true &url=<?php echo get_the_guid(); ?> &colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" id="facebook-like"> </iframe> <?php }
public static function meta_box_callback() { ?> <div> <span id="guid_preview"><?php echo get_the_guid(); ?> </span> <a href="#" id="regenerate_guid"><?php echo __('regenerate', 'podlove'); ?> </a> </div> <span class="description"> <?php echo __('Identifier for this episode. Change it to force podcatchers to redownload media files for this episode.', 'podlove'); ?> </span> <input type="hidden" name="_podlove_meta[guid]" id="_podlove_meta_guid" value="<?php echo get_the_guid(); ?> "> <script type="text/javascript"> jQuery(function($){ $("#regenerate_guid").on('click', function(e) { e.preventDefault(); var data = { action: 'podlove-get-new-guid', post_id: jQuery("#post_ID").val() }; $.ajax({ url: ajaxurl, data: data, dataType: 'json', success: function(result) { if (result && result.guid) { $("#_podlove_meta_guid").val(result.guid); $("#guid_preview").html(result.guid); if ( ! $(".guid_warning").length ) { $(".row__podlove_meta_guid .description") .append("<br><strong class=\"guid_warning\">GUID regenerated. You still need to save the post.<br>Only regenerate if you messed up and need all clients to redownload all files!</strong>"); } } else { alert("Sorry, couldn't generate new GUID."); } } }); return false; }); }); </script> <?php }
function albr_beforePost($data, $postarr) { if (!get_option('albr_setImgStetting')) { return $data; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $data; } $content = $data['post_content']; if (!substr_count($content, '<img')) { return $data; } $urlsForRepl = findScr($content); if (count($urlsForRepl)) { foreach ($urlsForRepl as $item) { $repl = get_the_guid(loadImg($item)); $content = str_replace($item, $repl, $content); } } $data['post_content'] = $content; return $data; }
function xtreme_get_gallery_attachment_url($post_id = 0, $target_size) { $post_id = (int) $post_id; if (!($post =& get_post($post_id))) { return false; } if ('attachment' != $post->post_type) { return false; } $imagedata = wp_get_attachment_metadata($post->ID); $file = is_array($imagedata) && isset($imagedata['sizes'][$target_size]) ? dirname(get_post_meta($post->ID, '_wp_attached_file', true)) . '/' . $imagedata['sizes'][$target_size]['file'] : get_post_meta($post->ID, '_wp_attached_file', true); $url = ''; if ($file) { //Get attached file if (($uploads = wp_upload_dir()) && false === $uploads['error']) { //Get upload directory if (0 === strpos($file, $uploads['basedir'])) { //Check that the upload base exists in the file location $url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); } elseif (false !== strpos($file, 'wp-content/uploads')) { $url = $uploads['baseurl'] . substr($file, strpos($file, 'wp-content/uploads') + 18); } else { $url = $uploads['baseurl'] . "/{$file}"; } //Its a newly uploaded file, therefor $file is relative to the basedir. } } if (empty($url)) { //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recommended to rely upon this. $url = get_the_guid($post->ID); } if (empty($url)) { return false; } return $url; }
/** * @param $job_object * @return bool */ public function job_run(BackWPup_Job $job_object) { global $wpdb, $post, $wp_query; $wxr_version = '1.2'; if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) { $job_object->log(sprintf(__('%d. Trying to create a WordPress export to XML file …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY'])); $job_object->steps_data[$job_object->step_working]['wpexportfile'] = BackWPup::get_plugin_data('TEMP') . $job_object->generate_filename($job_object->job['wpexportfile'], 'xml', TRUE); $job_object->steps_data[$job_object->step_working]['substep'] = 'header'; $job_object->steps_data[$job_object->step_working]['post_ids'] = array(); $job_object->substeps_todo = 10; $job_object->substeps_done = 0; } add_filter('wxr_export_skip_postmeta', array($this, 'wxr_filter_postmeta'), 10, 2); if ($job_object->steps_data[$job_object->step_working]['substep'] == 'header') { if ('all' != $job_object->job['wpexportcontent'] && post_type_exists($job_object->job['wpexportcontent'])) { $ptype = get_post_type_object($job_object->job['wpexportcontent']); if (!$ptype->can_export) { $job_object->log(sprintf(__('WP Export: Post type “%s” does not allow export.', 'backwpup'), $job_object->job['wpexportcontent']), E_USER_ERROR); return FALSE; } $where = $wpdb->prepare("{$wpdb->posts}.post_type = %s", $job_object->job['wpexportcontent']); } else { $post_types = get_post_types(array('can_export' => true)); $esses = array_fill(0, count($post_types), '%s'); $where = $wpdb->prepare("{$wpdb->posts}.post_type IN (" . implode(',', $esses) . ')', $post_types); $job_object->job['wpexportcontent'] = 'all'; } $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'"; // grab a snapshot of post IDs, just in case it changes during the export $job_object->steps_data[$job_object->step_working]['post_ids'] = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE {$where}"); $job_object->substeps_todo = $job_object->substeps_todo + count($job_object->steps_data[$job_object->step_working]['post_ids']); $header = '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n"; $header .= "<!-- This is a WordPress eXtended RSS file generated by the WordPress plugin BackWPup as an export of your site. -->\n"; $header .= "<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->\n"; $header .= "<!-- You may use this file to transfer that content from one site to another. -->\n"; $header .= "<!-- This file is not intended to serve as a complete backup of your site. -->\n\n"; $header .= "<!-- To import this information into a WordPress site follow these steps: -->\n"; $header .= "<!-- 1. Log in to that site as an administrator. -->\n"; $header .= "<!-- 2. Go to Tools: Import in the WordPress admin panel. -->\n"; $header .= "<!-- 3. Install the \"WordPress\" importer from the list. -->\n"; $header .= "<!-- 4. Activate & Run Importer. -->\n"; $header .= "<!-- 5. Upload this file using the form provided on that page. -->\n"; $header .= "<!-- 6. You will first be asked to map the authors in this export file to users -->\n"; $header .= "<!-- on the site. For each author, you may choose to map to an -->\n"; $header .= "<!-- existing user on the site or to create a new user. -->\n"; $header .= "<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->\n"; $header .= "<!-- contained in this file into your site. -->\n\n"; $header .= "<!-- generator=\"WordPress/" . get_bloginfo_rss('version') . "\" created=\"" . date('Y-m-d H:i') . "\" -->\n"; $header .= "<rss version=\"2.0\" xmlns:excerpt=\"http://wordpress.org/export/{$wxr_version}/excerpt/\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:wp=\"http://wordpress.org/export/{$wxr_version}/\">\n"; $header .= "<channel>\n"; $header .= "\t<title>" . get_bloginfo_rss('name') . "</title>\n"; $header .= "\t<link>" . get_bloginfo_rss('url') . "</link>\n"; $header .= "\t<description>" . get_bloginfo_rss('description') . "</description>\n"; $header .= "\t<pubDate>" . date('D, d M Y H:i:s +0000') . "</pubDate>\n"; $header .= "\t<language>" . get_bloginfo_rss('language') . "</language>\n"; $header .= "\t<wp:wxr_version>" . $wxr_version . "</wp:wxr_version>\n"; $header .= "\t<wp:base_site_url>" . $this->wxr_site_url() . "</wp:base_site_url>\n"; $header .= "\t<wp:base_blog_url>" . get_bloginfo_rss('url') . "</wp:base_blog_url>\n"; $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $header, FILE_APPEND); if ($written === FALSE) { $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR); return FALSE; } unset($header); $job_object->steps_data[$job_object->step_working]['substep'] = 'authors'; $job_object->substeps_done++; $job_object->update_working_data(); $job_object->do_restart_time(); } if ($job_object->steps_data[$job_object->step_working]['substep'] == 'authors') { $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $this->wxr_authors_list(), FILE_APPEND); if ($written === FALSE) { $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR); return FALSE; } $job_object->steps_data[$job_object->step_working]['substep'] = 'cats'; $job_object->substeps_done++; $job_object->update_working_data(); $job_object->do_restart_time(); } if ($job_object->steps_data[$job_object->step_working]['substep'] == 'cats') { if ('all' == $job_object->job['wpexportcontent']) { $cats = array(); $categories = (array) get_categories(array('get' => 'all')); // put categories in order with no child going before its parent while ($cat = array_shift($categories)) { if ($cat->parent == 0 || isset($cats[$cat->parent])) { $cats[$cat->term_id] = $cat; } else { $categories[] = $cat; } } $cats_xml = ''; foreach ($cats as $c) { $parent_slug = $c->parent ? $cats[$c->parent]->slug : ''; $cats_xml .= "\t<wp:category><wp:term_id>" . $c->term_id . "</wp:term_id><wp:category_nicename>" . $c->slug . "</wp:category_nicename><wp:category_parent>" . $parent_slug . "</wp:category_parent>" . $this->wxr_cat_name($c) . $this->wxr_category_description($c) . "</wp:category>\n"; } $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $cats_xml, FILE_APPEND); if ($written === FALSE) { $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR); return FALSE; } unset($cats_xml); } $job_object->steps_data[$job_object->step_working]['substep'] = 'tags'; $job_object->substeps_done++; $job_object->update_working_data(); $job_object->do_restart_time(); } if ($job_object->steps_data[$job_object->step_working]['substep'] == 'tags') { if ('all' == $job_object->job['wpexportcontent']) { $tags = (array) get_tags(array('get' => 'all')); $tags_xml = ''; foreach ($tags as $t) { $tags_xml .= "\t<wp:tag><wp:term_id>" . $t->term_id . "</wp:term_id><wp:tag_slug>" . $t->slug . "</wp:tag_slug>" . $this->wxr_tag_name($t) . $this->wxr_tag_description($t) . "</wp:tag>\n"; } $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $tags_xml, FILE_APPEND); if ($written === FALSE) { $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR); return FALSE; } unset($tags_xml); } $job_object->steps_data[$job_object->step_working]['substep'] = 'terms'; $job_object->substeps_done++; $job_object->update_working_data(); $job_object->do_restart_time(); } if ($job_object->steps_data[$job_object->step_working]['substep'] == 'terms') { if ('all' == $job_object->job['wpexportcontent']) { $terms = array(); $custom_taxonomies = get_taxonomies(array('_builtin' => false)); $custom_terms = (array) get_terms($custom_taxonomies, array('get' => 'all')); // put terms in order with no child going before its parent while ($t = array_shift($custom_terms)) { if ($t->parent == 0 || isset($terms[$t->parent])) { $terms[$t->term_id] = $t; } else { $custom_terms[] = $t; } } $terms_xml = ''; foreach ($terms as $t) { $parent_slug = $t->parent ? $terms[$t->parent]->slug : ''; $terms_xml .= "\t<wp:term><wp:term_id>" . $t->term_id . "</wp:term_id><wp:term_taxonomy>" . $t->taxonomy . "</wp:term_taxonomy><wp:term_slug>" . $t->slug . "</wp:term_slug><wp:term_parent>" . $parent_slug . "</wp:term_parent>" . $this->wxr_term_name($t) . $this->wxr_term_description($t) . "</wp:term>\n"; } $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $terms_xml, FILE_APPEND); if ($written === FALSE) { $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR); return FALSE; } unset($terms_xml); } $job_object->steps_data[$job_object->step_working]['substep'] = 'menus'; $job_object->substeps_done++; $job_object->update_working_data(); $job_object->do_restart_time(); } if ($job_object->steps_data[$job_object->step_working]['substep'] == 'menus') { $menu_xml = ''; if ('all' == $job_object->job['wpexportcontent']) { $menu_xml .= $this->wxr_nav_menu_terms(); } $menu_xml .= "\t<generator>http://wordpress.org/?v=" . get_bloginfo_rss('version') . "</generator>\n"; $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $menu_xml, FILE_APPEND); if ($written === FALSE) { $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR); return FALSE; } unset($menu_xml); $job_object->steps_data[$job_object->step_working]['substep'] = 'posts'; $job_object->substeps_done++; $job_object->update_working_data(); $job_object->do_restart_time(); } if ($job_object->steps_data[$job_object->step_working]['substep'] == 'posts') { if (!empty($job_object->steps_data[$job_object->step_working]['post_ids'])) { $wp_query->in_the_loop = true; // Fake being in the loop. // fetch 20 posts at a time rather than loading the entire table into memory while ($next_posts = array_splice($job_object->steps_data[$job_object->step_working]['post_ids'], 0, 20)) { $where = 'WHERE ID IN (' . join(',', $next_posts) . ')'; $posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} {$where}"); $wxr_post = ''; // Begin Loop foreach ($posts as $post) { /* @var WP_Post $post */ $is_sticky = is_sticky($post->ID) ? 1 : 0; $wxr_post .= "\t<item>\n"; $wxr_post .= "\t\t<title>" . apply_filters('the_title_rss', $post->post_title) . "</title>\n"; $wxr_post .= "\t\t<link>" . esc_url(apply_filters('the_permalink_rss', get_permalink($post))) . "</link>\n"; $wxr_post .= "\t\t<pubDate>" . mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true, $post), false) . "</pubDate>\n"; $wxr_post .= "\t\t<dc:creator>" . $this->wxr_cdata(get_the_author_meta('login', $post->post_author)) . "</dc:creator>\n"; $wxr_post .= "\t\t<guid isPermaLink=\"false\">" . esc_url(get_the_guid($post->ID)) . "</guid>\n"; $wxr_post .= "\t\t<description></description>\n"; $wxr_post .= "\t\t<content:encoded>" . $this->wxr_cdata(apply_filters('the_content_export', $post->post_content)) . "</content:encoded>\n"; $wxr_post .= "\t\t<excerpt:encoded>" . $this->wxr_cdata(apply_filters('the_excerpt_export', $post->post_excerpt)) . "</excerpt:encoded>\n"; $wxr_post .= "\t\t<wp:post_id>" . $post->ID . "</wp:post_id>\n"; $wxr_post .= "\t\t<wp:post_date>" . $post->post_date . "</wp:post_date>\n"; $wxr_post .= "\t\t<wp:post_date_gmt>" . $post->post_date_gmt . "</wp:post_date_gmt>\n"; $wxr_post .= "\t\t<wp:comment_status>" . $post->comment_status . "</wp:comment_status>\n"; $wxr_post .= "\t\t<wp:ping_status>" . $post->ping_status . "</wp:ping_status>\n"; $wxr_post .= "\t\t<wp:post_name>" . $post->post_name . "</wp:post_name>\n"; $wxr_post .= "\t\t<wp:status>" . $post->post_status . "</wp:status>\n"; $wxr_post .= "\t\t<wp:post_parent>" . $post->post_parent . "</wp:post_parent>\n"; $wxr_post .= "\t\t<wp:menu_order>" . $post->menu_order . "</wp:menu_order>\n"; $wxr_post .= "\t\t<wp:post_type>" . $post->post_type . "</wp:post_type>\n"; $wxr_post .= "\t\t<wp:post_password>" . $post->post_password . "</wp:post_password>\n"; $wxr_post .= "\t\t<wp:is_sticky>" . $is_sticky . "</wp:is_sticky>\n"; if ($post->post_type == 'attachment') { $wxr_post .= "\t\t<wp:attachment_url>" . wp_get_attachment_url($post->ID) . "</wp:attachment_url>\n"; } $wxr_post .= $this->wxr_post_taxonomy(); $postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE post_id = %d", $post->ID)); foreach ($postmeta as $meta) { if (apply_filters('wxr_export_skip_postmeta', false, $meta->meta_key, $meta)) { continue; } $wxr_post .= "\t\t<wp:postmeta>\n\t\t\t<wp:meta_key>" . $meta->meta_key . "</wp:meta_key>\n\t\t\t<wp:meta_value>" . $this->wxr_cdata($meta->meta_value) . "</wp:meta_value>\n\t\t</wp:postmeta>\n"; } $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID)); foreach ($comments as $c) { $wxr_post .= "\t\t<wp:comment>\n"; $wxr_post .= "\t\t\t<wp:comment_id>" . $c->comment_ID . "</wp:comment_id>\n"; $wxr_post .= "\t\t\t<wp:comment_author>" . $this->wxr_cdata($c->comment_author) . "</wp:comment_author>\n"; $wxr_post .= "\t\t\t<wp:comment_author_email>" . $c->comment_author_email . "</wp:comment_author_email>\n"; $wxr_post .= "\t\t\t<wp:comment_author_url>" . esc_url_raw($c->comment_author_url) . "</wp:comment_author_url>\n"; $wxr_post .= "\t\t\t<wp:comment_author_IP>" . $c->comment_author_IP . "</wp:comment_author_IP>\n"; $wxr_post .= "\t\t\t<wp:comment_date>" . $c->comment_date . "</wp:comment_date>\n"; $wxr_post .= "\t\t\t<wp:comment_date_gmt>" . $c->comment_date_gmt . "</wp:comment_date_gmt>\n"; $wxr_post .= "\t\t\t<wp:comment_content>" . $this->wxr_cdata($c->comment_content) . "</wp:comment_content>\n"; $wxr_post .= "\t\t\t<wp:comment_approved>" . $c->comment_approved . "</wp:comment_approved>\n"; $wxr_post .= "\t\t\t<wp:comment_type>" . $c->comment_type . "</wp:comment_type>\n"; $wxr_post .= "\t\t\t<wp:comment_parent>" . $c->comment_parent . "</wp:comment_parent>\n"; $wxr_post .= "\t\t\t<wp:comment_user_id>" . $c->user_id . "</wp:comment_user_id>\n"; $c_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->commentmeta} WHERE comment_id = %d", $c->comment_ID)); foreach ($c_meta as $meta) { $wxr_post .= "\t\t\t<wp:commentmeta>\n\t\t\t\t<wp:meta_key>" . $meta->meta_key . "</wp:meta_key>\n\t\t\t\t<wp:meta_value>" . $this->wxr_cdata($meta->meta_value) . "</wp:meta_value>\n\t\t\t</wp:commentmeta>\n"; } $wxr_post .= "\t\t</wp:comment>\n"; } $wxr_post .= "\t</item>\n"; $job_object->substeps_done++; } $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], $wxr_post, FILE_APPEND); if ($written === FALSE) { $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR); return FALSE; } $job_object->do_restart_time(); } } $written = file_put_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'], "</channel>\n</rss>", FILE_APPEND); if ($written === FALSE) { $job_object->log(__('WP Export file could not written.', 'backwpup'), E_USER_ERROR); return FALSE; } $job_object->steps_data[$job_object->step_working]['substep'] = 'check'; $job_object->substeps_done++; $job_object->update_working_data(); $job_object->do_restart_time(); } remove_filter('wxr_export_skip_postmeta', array($this, 'wxr_filter_postmeta'), 10); if ($job_object->steps_data[$job_object->step_working]['substep'] == 'check') { if (extension_loaded('simplexml') && class_exists('DOMDocument')) { $job_object->log(__('Check WP Export file …', 'backwpup')); $job_object->need_free_memory(filesize($job_object->steps_data[$job_object->step_working]['wpexportfile']) * 2); $valid = TRUE; $internal_errors = libxml_use_internal_errors(TRUE); $dom = new DOMDocument(); $old_value = NULL; if (function_exists('libxml_disable_entity_loader')) { $old_value = libxml_disable_entity_loader(TRUE); } $success = $dom->loadXML(file_get_contents($job_object->steps_data[$job_object->step_working]['wpexportfile'])); if (!is_null($old_value)) { libxml_disable_entity_loader($old_value); } if (!$success || isset($dom->doctype)) { $errors = libxml_get_errors(); $valid = FALSE; foreach ($errors as $error) { switch ($error->level) { case LIBXML_ERR_WARNING: $job_object->log(E_USER_WARNING, sprintf(__('XML WARNING (%s): %s', 'backwpup'), $error->code, trim($error->message)), $job_object->steps_data[$job_object->step_working]['wpexportfile'], $error->line); break; case LIBXML_ERR_ERROR: $job_object->log(E_USER_WARNING, sprintf(__('XML RECOVERABLE (%s): %s', 'backwpup'), $error->code, trim($error->message)), $job_object->steps_data[$job_object->step_working]['wpexportfile'], $error->line); break; case LIBXML_ERR_FATAL: $job_object->log(E_USER_WARNING, sprintf(__('XML ERROR (%s): %s', 'backwpup'), $error->code, trim($error->message)), $job_object->steps_data[$job_object->step_working]['wpexportfile'], $error->line); break; } } } else { $xml = simplexml_import_dom($dom); unset($dom); // halt if loading produces an error if (!$xml) { $job_object->log(__('There was an error when reading this WXR file', 'backwpup'), E_USER_ERROR); $valid = FALSE; } else { $wxr_version = $xml->xpath('/rss/channel/wp:wxr_version'); if (!$wxr_version) { $job_object->log(__('This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup'), E_USER_ERROR); $valid = FALSE; } $wxr_version = (string) trim($wxr_version[0]); // confirm that we are dealing with the correct file format if (!preg_match('/^\\d+\\.\\d+$/', $wxr_version)) { $job_object->log(__('This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup'), E_USER_ERROR); $valid = FALSE; } } } libxml_use_internal_errors($internal_errors); if ($valid) { $job_object->log(__('WP Export file is a valid WXR file.', 'backwpup')); } } else { $job_object->log(__('WP Export file can not be checked, because no XML extension is loaded, to ensure the file verification.', 'backwpup')); } $job_object->steps_data[$job_object->step_working]['substep'] = 'compress'; $job_object->substeps_done++; $job_object->update_working_data(); $job_object->do_restart_time(); } //Compress file if ($job_object->steps_data[$job_object->step_working]['substep'] == 'compress') { if (!empty($job_object->job['wpexportfilecompression'])) { $job_object->log(__('Compressing file …', 'backwpup')); try { $compress = new BackWPup_Create_Archive($job_object->steps_data[$job_object->step_working]['wpexportfile'] . $job_object->job['wpexportfilecompression']); if ($compress->add_file($job_object->steps_data[$job_object->step_working]['wpexportfile'])) { unset($compress); unlink($job_object->steps_data[$job_object->step_working]['wpexportfile']); $job_object->steps_data[$job_object->step_working]['wpexportfile'] .= $job_object->job['wpexportfilecompression']; $job_object->log(__('Compressing done.', 'backwpup')); } } catch (Exception $e) { $job_object->log($e->getMessage(), E_USER_ERROR, $e->getFile(), $e->getLine()); unset($compress); return FALSE; } } $job_object->steps_data[$job_object->step_working]['substep'] = 'addfile'; $job_object->substeps_done++; $job_object->update_working_data(); $job_object->do_restart_time(); } if ($job_object->steps_data[$job_object->step_working]['substep'] == 'addfile') { //add XML file to backup files if (is_readable($job_object->steps_data[$job_object->step_working]['wpexportfile'])) { $job_object->additional_files_to_backup[] = $job_object->steps_data[$job_object->step_working]['wpexportfile']; $filesize = filesize($job_object->steps_data[$job_object->step_working]['wpexportfile']); $job_object->log(sprintf(__('Added XML export "%1$s" with %2$s to backup file list.', 'backwpup'), basename($job_object->steps_data[$job_object->step_working]['wpexportfile']), size_format($filesize, 2))); } $job_object->substeps_done++; $job_object->update_working_data(); } return TRUE; }
/** * Show additional file info * * @since 1.9.2 * @param int $post_id Item ID * @return void */ function sell_media_show_file_info() { $post = get_post(); $attachment_id = sell_media_get_attachment_id($post->ID); $media_dims = ''; $meta = wp_get_attachment_metadata($attachment_id); $filename = basename(get_attached_file($attachment_id)); $postguid = get_the_guid($attachment_id); echo '<h2 class="widget-title sell-media-item-details-title">' . __('Details', 'sell_media') . '</h2>'; echo '<ul class="sell-media-item-details">'; echo '<li class="filename"><span class="title">' . __('File Name', 'sell_media') . ':</span> ' . $filename . '</li>'; echo '<li class="fileid"><span class="title">' . __('File ID', 'sell_media') . ':</span> ' . $attachment_id . '</li>'; preg_match('/^.*?\\.(\\w+)$/', $filename, $ext); echo '<li class="filetype"><span class="title">' . __('File Type', 'sell_media') . ':</span> ' . esc_html(strtoupper($ext[1])) . ' (' . get_post_mime_type($attachment_id) . ')</li>'; echo '<li class="filesize"><span class="title">' . __('File Size', 'sell_media') . ':</span> ' . sell_media_get_filesize($post->ID, $attachment_id) . '</li>'; if (isset($meta['width'], $meta['height'])) { echo '<li class="filedims"><span class="title">' . __('Dimensions', 'sell_media') . ':</span> ' . $meta['width'] . ' x ' . $meta['height'] . '</li>'; } if (wp_get_post_terms($post->ID, 'collection')) { echo '<li class="collections"><span class="title">' . __('Collections', 'sell_media') . ':</span> ' . sell_media_get_taxonomy_terms('collection') . '</li>'; } if (wp_get_post_terms($post->ID, 'keywords') && !get_query_var('id')) { echo '<li class="keywords"><span class="title">' . __('Keywords', 'sell_media') . ':</span> ' . sell_media_get_taxonomy_terms('keywords') . '</li>'; } if (preg_match('#^(audio|video)/#', get_post_mime_type($attachment_id))) { echo '<li class="length"><span class="title">' . __('Length', 'sell_media') . ':</span> ' . $meta['length_formatted'] . '</li>'; echo '<li class="bitrate"><span class="title">' . __('Bitrate', 'sell_media') . ':</span> ' . round($meta['bitrate'] / 1000) . 'kb/s</li>'; } echo do_action('sell_media_additional_list_items', $post->ID); echo '</ul>'; }
/** * _transition_post_status() - Hook {@internal Missing Short Description}} * * {@internal Missing Long Description}} * * @package WordPress * @subpackage Post * @since 2.3 * * @uses $wpdb * * @param string $new_status {@internal Missing Description}} * @param string $old_status {@internal Missing Description}} * @param object $post Object type containing the post information */ function _transition_post_status($new_status, $old_status, $post) { global $wpdb; if ($old_status != 'publish' && $new_status == 'publish') { // Reset GUID if transitioning to publish and it is empty if ('' == get_the_guid($post->ID)) { $wpdb->update($wpdb->posts, array('guid' => get_permalink($post->ID)), array('ID' => $post->ID)); } do_action('private_to_published', $post->ID); // Deprecated, use private_to_publish } // Always clears the hook in case the post status bounced from future to draft. wp_clear_scheduled_hook('publish_future_post', $post->ID); }
/** * Hook for managing future post transitions to published. * * @since 2.3.0 * @access private * * @see wp_clear_scheduled_hook() * @global wpdb $wpdb WordPress database abstraction object. * * @param string $new_status New post status. * @param string $old_status Previous post status. * @param WP_Post $post Post object. */ function _transition_post_status($new_status, $old_status, $post) { global $wpdb; if ($old_status != 'publish' && $new_status == 'publish') { // Reset GUID if transitioning to publish and it is empty. if ('' == get_the_guid($post->ID)) { $wpdb->update($wpdb->posts, array('guid' => get_permalink($post->ID)), array('ID' => $post->ID)); } /** * Fires when a post's status is transitioned from private to published. * * @since 1.5.0 * @deprecated 2.3.0 Use 'private_to_publish' instead. * * @param int $post_id Post ID. */ do_action('private_to_published', $post->ID); } // If published posts changed clear the lastpostmodified cache. if ('publish' == $new_status || 'publish' == $old_status) { foreach (array('server', 'gmt', 'blog') as $timezone) { wp_cache_delete("lastpostmodified:{$timezone}", 'timeinfo'); wp_cache_delete("lastpostdate:{$timezone}", 'timeinfo'); wp_cache_delete("lastpostdate:{$timezone}:{$post->post_type}", 'timeinfo'); } } if ($new_status !== $old_status) { wp_cache_delete(_count_posts_cache_key($post->post_type), 'counts'); wp_cache_delete(_count_posts_cache_key($post->post_type, 'readable'), 'counts'); } // Always clears the hook in case the post status bounced from future to draft. wp_clear_scheduled_hook('publish_future_post', array($post->ID)); }
$image_10 = get_the_guid(82); $link_10 = get_permalink(25); $image_11 = get_the_guid(83); $link_11 = get_permalink(32); $image_12 = get_the_guid(84); $link_12 = "http://mathildedufort.tumblr.com/"; $image_13 = get_the_guid(85); $link_13 = get_permalink(175); // row 4 $image_14 = get_the_guid(86); $link_14 = get_permalink(39); $image_15 = get_the_guid(87); $link_15 = get_permalink(48); $image_16 = get_the_guid(88); $link_16 = get_permalink(46); $image_17 = get_the_guid(89); $link_17 = get_permalink(27); ?> <?php get_header(); ?> <div id="header"> <h1>MATHILDE DUFORT</h1> <h2>Graphiste freelance</h2> <p id="header_link_p"><a href="mailto:mathildedufort@hotmail.com">mathildedufort@hotmail.com</a> - 06 62 89 94 26</p> </div> <div id="main_container">
function the_guid($id = 0) { echo get_the_guid($id); }
public function post($post) { $oxymel = new WP_Export_Oxymel(); $GLOBALS['wp_query']->in_the_loop = true; $GLOBALS['post'] = $post; setup_postdata($post); $oxymel->item->contains->title(apply_filters('the_title_rss', $post->post_title))->link(esc_url(apply_filters('the_permalink_rss', get_permalink())))->pubDate(mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false))->tag('dc:creator', get_the_author_meta('login'))->guid(esc_url(get_the_guid()), array('isPermaLink' => 'false'))->description('')->tag('content:encoded')->contains->cdata($post->post_content)->end->tag('excerpt:encoded')->contains->cdata($post->post_excerpt)->end->tag('wp:post_id', $post->ID)->tag('wp:post_date', $post->post_date)->tag('wp:post_date_gmt', $post->post_date_gmt)->tag('wp:comment_status', $post->comment_status)->tag('wp:ping_status', $post->ping_status)->tag('wp:post_name', $post->post_name)->tag('wp:status', $post->post_status)->tag('wp:post_parent', $post->post_parent)->tag('wp:menu_order', $post->menu_order)->tag('wp:post_type', $post->post_type)->tag('wp:post_password', $post->post_password)->tag('wp:is_sticky', $post->is_sticky)->optional('wp:attachment_url', wp_get_attachment_url($post->ID)); foreach ($post->terms as $term) { $oxymel->category(array('domain' => $term->taxonomy, 'nicename' => $term->slug))->contains->cdata($term->name)->end; } foreach ($post->meta as $meta) { $oxymel->tag('wp:postmeta')->contains->tag('wp:meta_key', $meta->meta_key)->tag('wp:meta_value')->contains->cdata($meta->meta_value)->end->end; } foreach ($post->comments as $comment) { $oxymel->tag('wp:comment')->contains->tag('wp:comment_id', $comment->comment_ID)->tag('wp:comment_author')->contains->cdata($comment->comment_author)->end->tag('wp:comment_author_email', $comment->comment_author_email)->tag('wp:comment_author_url', esc_url($comment->comment_author_url))->tag('wp:comment_author_IP', $comment->comment_author_IP)->tag('wp:comment_date', $comment->comment_date)->tag('wp:comment_date_gmt', $comment->comment_date_gmt)->tag('wp:comment_content')->contains->cdata($comment->comment_content)->end->tag('wp:comment_approved', $comment->comment_approved)->tag('wp:comment_type', $comment->comment_type)->tag('wp:comment_parent', $comment->comment_parent)->tag('wp:comment_user_id', $comment->user_id)->oxymel($this->comment_meta($comment))->end; } $oxymel->end; return $oxymel->to_string(); }
/** * Retrieve the feed GUID for the current comment. * * @package WordPress * @subpackage Feed * @since unknown * * @return bool|string false on failure or guid for comment on success. */ function get_comment_guid() { global $comment; if (!is_object($comment)) { return false; } return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID; }
/** * Retrieve the feed GUID for the current comment. * * @since 2.5.0 * * @param int|object $comment_id Optional comment object or id. Defaults to global comment object. * @return false|string false on failure or guid for comment on success. */ function get_comment_guid($comment_id = null) { $comment = get_comment($comment_id); if (!is_object($comment)) { return false; } return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID; }
function dynamic_inline_style() { $custom_css = ''; $main_color = get_theme_mod('main_color'); if ($main_color == '' || $main_color == NULL) { $main_color = '#D12F2F'; } $bg_color = get_theme_mod('background-color'); if ($bg_color == '' || $bg_color == NULL) { $bg_color = '#E5E5E5'; } $bg_img = get_theme_mod('background-image'); $em_font = get_theme_mod('emphasis-font'); if ($em_font == '' || $em_font == NULL) { $em_font = 'font-62'; } $body_font = get_theme_mod('body-font'); if ($body_font == '' || $body_font == NULL) { $body_font = 'font-0'; } $em_font_index = (int) substr($em_font, strpos($em_font, '-') + 1); $body_font_index = (int) substr($body_font, strpos($body_font, '-') + 1); // dynamic inline css if ($main_color) { $custom_css .= 'a, #top-page-list ul li a, .news-box.break li h3.title a:hover, #flexible-home-layout-section .news-box .meta a:hover, .post-wrapper .meta > div:hover, .related-post .meta a:hover, .related-news .meta a:hover, #flexible-home-layout-section .news-box.slider h3.title a:hover, .post-header .meta a:hover, #copyright a:hover, #selectnav2 { color: ' . $main_color . '; } ::-webkit-scrollbar-thumb { background-color: ' . $main_color . '; } .header-line-2, #drop-down-menu > div > ul > li:hover > a, #drop-down-menu ul.sub-menu li a:hover, #flexible-home-layout-section .news-box h2.title a, #flexible-home-layout-section .news-box.hot .item-first, #flexible-home-layout-section .news-box.slider .dots li.active, .tagcloud a, #respond form #submit, #contact-form .show-all a { background-color: ' . $main_color . '; } .post-body blockquote { border-top-color: ' . $main_color . '; }'; } if ($bg_color || $bg_img) { $custom_css .= 'body { ' . ($bg_img ? 'background-image: url(' . $bg_img . ');' : '') . ($bg_color ? 'background-color: ' . $bg_color . ';' : '') . ' }'; } $em_font_text = 'Oswald'; $body_font_text = 'Arial'; // google font if ($em_font && $body_font) { global $Google_Font_List; // loading google fonts if (strpos($em_font, 'cufont') === false) { $em_font_text = $Google_Font_List[$em_font_index]; if ($em_font_index > 6) { echo '<link href="http://fonts.googleapis.com/css?family=' . str_replace(' ', '+', $em_font_text) . '" rel="stylesheet" type="text/css">'; /* $custom_css .=' @import url(http://fonts.googleapis.com/css?family='.str_replace(' ', '+', $em_font_text).');'; */ } } else { $fid = get_the_ID($em_font_index); $fname = get_the_title($em_font_index); $fguid = get_the_guid($em_font_index); $custom_css .= '@font-face { font-family: \'' . $fname . '\'; src: url(' . $fguid . ') format(\'woff\'); }'; $em_font_text = $fname; } if (strpos($body_font, 'cufont') === false) { $body_font_text = $Google_Font_List[$body_font_index]; if ($body_font_index > 6) { echo '<link href="http://fonts.googleapis.com/css?family=' . str_replace(' ', '+', $body_font_text) . '" rel="stylesheet" type="text/css">'; /* $custom_css .=' @import url(http://fonts.googleapis.com/css?family='.str_replace(' ', '+', $body_font_text).');'; */ } } else { $fid = get_the_ID($body_font_index); $fname = get_the_title($body_font_index); $fguid = get_the_guid($body_font_index); $custom_css .= '@font-face { font-family: \'' . $fname . '\'; src: url(' . $fguid . ') format(\'woff\'); }'; $body_font_text = $fname; } $custom_css .= ' body, #drop-down-menu ul.sub-menu li a{ font-family: ' . $body_font_text . '; } .blog-title, #drop-down-menu, #flexible-home-layout-section .news-box h2.title, #flexible-home-layout-section .news-box h3.title, h1.post-title, .post-body blockquote, .post-apps a, .zoom-text span, h2.archive-post-title, #side h2.widget-title, .widget_feed_data_widget .item .title, #footer-section .widget-title, .tagcloud a, #post-footer-section .widget .widget-title , .share-post .title, .related-news h3.title, .post-author .author-info h4, .page-numbers, .paginations .item a, #reply-title, .img-404, a.home-from-none, #contact-form .label, #contact-form .show-all a, #selectnav2 { font-family: \'' . $em_font_text . '\', sans-serif; }'; } wp_add_inline_style('theme-style', $custom_css); // dynamic inline javascript if (is_home() || get_theme_mod('break_box') == true) { echo '<script type="text/javascript"> var TICKER_DELAY = ' . (get_theme_mod('ticker_delay') ? get_theme_mod('ticker_delay') : '7') . '; var SLIDER_DELAY = ' . (get_theme_mod('slider_delay') ? get_theme_mod('slider_delay') : '3000') . '; var SLIDER_SPEED = ' . (get_theme_mod('slider_speed') ? get_theme_mod('slider_speed') : '500') . '; </script>'; } }
* * Created by PhpStorm. * User: georgrokita * Date: 16.07.15 * Time: 18:16 */ get_header(); echo '<div id="primary" class="content-area">'; echo '<main id="main" class="site-main" role="main">'; $args = array('post_type' => 'event', 'posts_per_page' => 10); $loop = new WP_Query($args); while ($loop->have_posts()) { $loop->the_post(); $ID = get_the_ID(); $the_title = get_the_title(); $the_content = get_the_content(); $urlLink = get_the_guid(); echo '<article id="post-' . $ID . '" class="post-' . $ID . ' post type-post status-publish format-standard hentry category-allgemein">'; echo '<header class="entry-header"> <h1 class="entry-title"><a href="' . $urlLink . '" rel="bookmark">' . $the_title . '</a></h1> <div class="entry-meta"> <span class="posted-on"><a href="' . $urlLink . '" rel="bookmark"></span> <div class="entry-content"> <h4> ' . $the_content . '</h4> <p>' . $the_content . '</p> </div><!-- .entry-content -->'; the_excerpt(); echo '<footer class="entry-meta"> <span class="comments-link"><a href="http://localhost/wordpress/?p=45#respond" title="Kommentiere HTWK Eine Hochschule mit Unterstufenniveau">Hinterlassen Sie einen Kommentar</a></span> <span class="edit-link"><a class="post-edit-link" href="http://localhost/wordpress/wp-admin/post.php?post=' . $ID . '&action=edit">Editieren</a></span> </footer><!-- .entry-meta --> </article>'; }
public function guid() { return get_the_guid($this->raw); }
/** * Returns a guid for an individual reading in a reading plan * * @param integer $reading_id * @param integer $post_id * @return string guid */ function bfox_plan_reading_guid($reading_id, $post_id = 0) { return add_query_arg('reading', $reading_id, get_the_guid($post_id)); }
public function render_content() { global $Google_Font_List; ?> <!-- dynamic load google font --> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script> <script src="http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script> <script type="text/javascript"> <?php for ($i = 0; $i < count($Google_Font_List); $i++) { if ($i > 6) { echo 'WebFont.load({google: {families: ["' . $Google_Font_List[$i] . '"]}});'; } } ?> </script> <!-- style with google fonts --> <style type="text/css"> .font-style { display: block; height: 2em; font-size: 16px; } .font-style input { margin: 4px 5px 0 0; } .font-hr { background: #f0f0f0; padding: 5px; font-style: italic; color: #999; margin: 10px 0 5px 0; } .font-container { position: relative; height: 200px; overflow: auto; background: #fbfbfb; padding: 0 10px; border: 2px solid #ccc; } <?php for ($i = 0; $i < count($Google_Font_List); $i++) { echo '.font-style-' . $i . ' {font-family: ' . $Google_Font_List[$i] . ';}'; } // get custom font list $cufont = array(); $the_query = new WP_Query(array('post_status' => 'any', 'post_type' => 'attachment', 'post_mime_type' => 'font/opentype')); // The Loop if ($the_query->have_posts()) { $index = count($Google_Font_List); while ($the_query->have_posts()) { $the_query->the_post(); $fid = get_the_ID(); $fname = get_the_title(); $fguid = get_the_guid(); echo '@font-face { font-family: \'' . $fname . '\'; src: url(' . $fguid . ') format(\'woff\'); }'; echo '.font-style-' . $index . ' {font-family: ' . $fname . ';}'; $index++; $cufont['cufont-' . $fid] = $fname; } } /* Restore original Post Data */ wp_reset_postdata(); ?> </style> <span class="customize-control-title"><?php echo $this->label; ?> </span> <!-- output radio for fonts --> <?php $value = $this->value; if (!$value) { $value = 'font-62'; } echo '<div class="font-container">'; for ($i = 0; $i < count($Google_Font_List); $i++) { if ($i == 0) { echo '<div class="font-hr">System fonts</div>'; } if ($i == 7) { echo '<div class="font-hr">Webfonts</div>'; } echo '<label class="font-style font-style-' . $i . '"><input type="radio" value="font-' . $i . '" name="' . $this->id . '" ' . $this->get_link() . ' ' . ($value == 'font-' . $i ? 'checked' : '') . '/>' . $Google_Font_List[$i] . '<br/></label>'; } if (!empty($cufont)) { echo '<div class="font-hr">Uploaded Fonts</div>'; $index = count($Google_Font_List); foreach ($cufont as $key => $name) { echo '<label class="font-style font-style-' . $index . '"><input type="radio" value="' . $key . '" name="' . $this->id . '" ' . $this->get_link() . ' ' . ($value == $key ? 'checked' : '') . '/>' . $name . '<br/></label>'; $index++; } } echo '</div>'; }
/** * GUID should never be empty * @ticket 18310 * @ticket 21963 */ function test_insert_image_without_guid() { // this image is smaller than the thumbnail size so it won't have one $filename = DIR_TESTDATA . '/images/test-image.jpg'; $contents = file_get_contents($filename); $upload = wp_upload_bits(basename($filename), null, $contents); $this->assertTrue(empty($upload['error'])); $upload['url'] = ''; $id = $this->_make_attachment($upload); $guid = get_the_guid($id); $this->assertFalse(empty($guid)); }
$date = date('d M Y H:i:s', $event->start); $user_info = get_userdata($event->post->post_author); $location = str_replace("\n", ', ', rtrim($event->get_location())); $use_excerpt = Ai1ec_Meta::get_option('rss_use_excerpt'); $description = apply_filters('the_content', $event->post->post_content); if ($use_excerpt) { $description = Ai1ec_String_Utility::truncate_string_if_longer_than_x_words($description, 50, " <a href='{$permalink}' >" . __('Read more...', AI1EC_PLUGIN_NAME) . "</a>"); } $args = array('timespan' => $event->get_timespan_html(), 'location' => $location, 'permalink' => $permalink, 'description' => wpautop($description)); // Load the RSS specific template ob_start(); $ai1ec_view_helper->display_theme('event-feed-description.php', $args); $content = ob_get_contents(); ob_end_clean(); $user = $user_info->user_login; $guid = htmlspecialchars(get_the_guid($event->post_id)); $comments = esc_url(get_post_comments_feed_link($event->post_id, 'rss2')); $comments_number = get_comments_number($event->post_id); echo <<<FEED <item> \t<title>{$title}</title> \t<link>{$permalink}{$event->instance_id}</link> \t<pubDate>{$date}</pubDate> \t<dc:creator>{$user}</dc:creator> \t<guid isPermaLink="false">{$guid}</guid> \t<description><![CDATA[{$content}]]></description> \t<wfw:commentRss>{$comments}</wfw:commentRss> \t<slash:comments>{$comments_number}</slash:comments> </item> FEED; }
/** * API endpoint for front-end image uploading. */ public function upload() { global $content_width; header( 'Content-Type: application/json' ); if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'jetpack_comic_upload_nonce' ) ) die( json_encode( array( 'error' => __( 'Invalid or expired nonce.', 'jetpack' ) ) ) ); $_POST['action'] = 'wp_handle_upload'; $image_id_arr = array(); $image_error_arr = array(); $i = 0; while ( isset( $_FILES['image_' . $i ] ) ) { // Create attachment for the image. $image_id = media_handle_upload( "image_$i", 0 ); if ( is_wp_error( $image_id ) ) { $error = array( $image_id, $image_id->get_error_message() ); array_push( $image_error_arr, $error ); } else { array_push( $image_id_arr, $image_id ); } $i++; } if ( count( $image_id_arr ) == 0 ) { // All image uploads failed. $rv = array( 'error' => '' ); foreach ( $image_error_arr as $error ) $rv['error'] .= $error[1] . "\n"; } else { if ( count( $image_id_arr ) == 1 ) { $image_id = $image_id_arr[0]; // Get the image $image_src = get_the_guid( $image_id ); $image_dims = wp_get_attachment_image_src( $image_id, 'full' ); // Take off 10px of width to account for padding and border. @todo make this smarter. if ( $content_width ) $image_width = $content_width - 10; else $image_width = $image_dims[1] - 10; $post_content = '<a href="' . esc_attr( $image_src ) .'"><img src="' . esc_attr( $image_src ) . '?w=' . esc_attr( $image_width ) . '" alt="' . esc_attr( $_FILES['image_0']['name'] ) . '" class="size-full wp-image alignnone" id="i-' . esc_attr( $image_id ) . '" data-filename="' . esc_attr( $_FILES['image_0']['name'] ) . '" /></a>'; } else { $post_content = '[gallery ids="' . esc_attr( implode( ',', $image_id_arr ) ) . '"]'; } // Create a new post with the image(s) $post_id = wp_insert_post( array( 'post_content' => $post_content, 'post_type' => 'jetpack-comic', 'post_status' => 'draft', ), true ); if ( is_wp_error( $post_id, 'WP_Error' ) ) { // Failed to create the post. $rv = array( 'error' => $post_id->get_error_message() ); // Delete the uploaded images. foreach ( $image_id_arr as $image_id ) { wp_delete_post( $image_id, true ); } } else { foreach ( $image_id_arr as $image_id ) { wp_update_post( array( 'ID' => $image_id, 'post_parent' => $post_id ) ); } if ( current_theme_supports( 'post-thumbnails' ) && count( $image_id_arr ) == 1 ) set_post_thumbnail( $post_id, $image_id_arr[0] ); $rv = array( 'url' => add_query_arg( array( 'post' => $post_id, 'action' => 'edit' ), admin_url( 'post.php' ) ) ); } } die( json_encode( $rv ) ); }
/** * Generates the WXR export file for download * * @since 2.1.0 * * @param array $args Filters defining what should be included in the export */ function uncode_export_wp($args = array()) { global $wpdb, $post; $defaults = array('content' => 'all', 'author' => false, 'category' => false, 'start_date' => false, 'end_date' => false, 'status' => false); $args = wp_parse_args($args, $defaults); do_action('uncode_export_wp', $args); if ('all' != $args['content'] && post_type_exists($args['content'])) { $ptype = get_post_type_object($args['content']); if (!$ptype->can_export) { $args['content'] = 'post'; } $where = $wpdb->prepare("{$wpdb->posts}.post_type = %s", $args['content']); } else { $post_types = get_post_types(array('can_export' => true)); $esses = array_fill(0, count($post_types), '%s'); $where = $wpdb->prepare("{$wpdb->posts}.post_type IN (" . implode(',', $esses) . ')', $post_types); } if ($args['status'] && ('post' == $args['content'] || 'page' == $args['content'])) { $where .= $wpdb->prepare(" AND {$wpdb->posts}.post_status = %s", $args['status']); } else { $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'"; } $join = ''; if ($args['category'] && 'post' == $args['content']) { if ($term = term_exists($args['category'], 'category')) { $join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)"; $where .= $wpdb->prepare(" AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id']); } } if ('post' == $args['content'] || 'page' == $args['content']) { if ($args['author']) { $where .= $wpdb->prepare(" AND {$wpdb->posts}.post_author = %d", $args['author']); } if ($args['start_date']) { $where .= $wpdb->prepare(" AND {$wpdb->posts}.post_date >= %s", date('Y-m-d', strtotime($args['start_date']))); } if ($args['end_date']) { $where .= $wpdb->prepare(" AND {$wpdb->posts}.post_date < %s", date('Y-m-d', strtotime('+1 month', strtotime($args['end_date'])))); } } // grab a snapshot of post IDs, just in case it changes during the export $post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} {$join} WHERE {$where}"); // get the requested terms ready, empty unless posts filtered by category or all content $cats = $tags = $terms = array(); if (isset($term) && $term) { $cat = get_term($term['term_id'], 'category'); $cats = array($cat->term_id => $cat); unset($term, $cat); } else { if ('all' == $args['content']) { $categories = (array) get_categories(array('get' => 'all')); $tags = (array) get_tags(array('get' => 'all')); $custom_taxonomies = get_taxonomies(array('_builtin' => false)); $custom_terms = (array) get_terms($custom_taxonomies, array('get' => 'all')); // put categories in order with no child going before its parent while ($cat = array_shift($categories)) { if ($cat->parent == 0 || isset($cats[$cat->parent])) { $cats[$cat->term_id] = $cat; } else { $categories[] = $cat; } } // put terms in order with no child going before its parent while ($t = array_shift($custom_terms)) { if ($t->parent == 0 || isset($terms[$t->parent])) { $terms[$t->term_id] = $t; } else { $custom_terms[] = $t; } } unset($categories, $custom_taxonomies, $custom_terms); } } /** * Wrap given string in XML CDATA tag. * * @since 2.1.0 * * @param string $str String to wrap in XML CDATA tag. * @return string */ function wxr_cdata($str) { if (seems_utf8($str) == false) { $str = utf8_encode($str); } // $str = ent2ncr(esc_html($str)); $str = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $str) . ']]>'; return $str; } /** * Return the URL of the site * * @since 2.5.0 * * @return string Site URL. */ function wxr_site_url() { // ms: the base url if (is_multisite()) { return network_home_url(); } else { return get_bloginfo_rss('url'); } } /** * Output a cat_name XML tag from a given category object * * @since 2.1.0 * * @param object $category Category Object */ function wxr_cat_name($category) { if (empty($category->name)) { return; } echo '<wp:cat_name>' . wxr_cdata($category->name) . '</wp:cat_name>'; } /** * Output a category_description XML tag from a given category object * * @since 2.1.0 * * @param object $category Category Object */ function wxr_category_description($category) { if (empty($category->description)) { return; } echo '<wp:category_description>' . wxr_cdata($category->description) . '</wp:category_description>'; } /** * Output a tag_name XML tag from a given tag object * * @since 2.3.0 * * @param object $tag Tag Object */ function wxr_tag_name($tag) { if (empty($tag->name)) { return; } echo '<wp:tag_name>' . wxr_cdata($tag->name) . '</wp:tag_name>'; } /** * Output a tag_description XML tag from a given tag object * * @since 2.3.0 * * @param object $tag Tag Object */ function wxr_tag_description($tag) { if (empty($tag->description)) { return; } echo '<wp:tag_description>' . wxr_cdata($tag->description) . '</wp:tag_description>'; } /** * Output a term_name XML tag from a given term object * * @since 2.9.0 * * @param object $term Term Object */ function wxr_term_name($term) { if (empty($term->name)) { return; } echo '<wp:term_name>' . wxr_cdata($term->name) . '</wp:term_name>'; } /** * Output a term_description XML tag from a given term object * * @since 2.9.0 * * @param object $term Term Object */ function wxr_term_description($term) { if (empty($term->description)) { return; } echo '<wp:term_description>' . wxr_cdata($term->description) . '</wp:term_description>'; } /** * Output list of authors with posts * * @since 3.1.0 */ function wxr_authors_list() { global $wpdb; $authors = array(); $results = $wpdb->get_results("SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_status != 'auto-draft'"); foreach ((array) $results as $result) { $authors[] = get_userdata($result->post_author); } $authors = array_filter($authors); foreach ($authors as $author) { echo "\t<wp:author>"; echo '<wp:author_id>' . $author->ID . '</wp:author_id>'; echo '<wp:author_login>' . $author->user_login . '</wp:author_login>'; echo '<wp:author_email>' . $author->user_email . '</wp:author_email>'; echo '<wp:author_display_name>' . wxr_cdata($author->display_name) . '</wp:author_display_name>'; echo '<wp:author_first_name>' . wxr_cdata($author->user_firstname) . '</wp:author_first_name>'; echo '<wp:author_last_name>' . wxr_cdata($author->user_lastname) . '</wp:author_last_name>'; echo "</wp:author>\n"; } } /** * Ouput all navigation menu terms * * @since 3.1.0 */ function wxr_nav_menu_terms() { $nav_menus = wp_get_nav_menus(); if (empty($nav_menus) || !is_array($nav_menus)) { return; } foreach ($nav_menus as $menu) { echo "\t<wp:term><wp:term_id>{$menu->term_id}</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>{$menu->slug}</wp:term_slug>"; wxr_term_name($menu); echo "</wp:term>\n"; } } /** * Output list of taxonomy terms, in XML tag format, associated with a post * * @since 2.3.0 */ function wxr_post_taxonomy() { $post = get_post(); $taxonomies = get_object_taxonomies($post->post_type); if (empty($taxonomies)) { return; } $terms = wp_get_object_terms($post->ID, $taxonomies); foreach ((array) $terms as $term) { echo "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata($term->name) . "</category>\n"; } } function wxr_filter_postmeta($return_me, $meta_key) { if ('_edit_lock' == $meta_key) { $return_me = true; } return $return_me; } add_filter('wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2); echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n"; ?> <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. --> <!-- It contains information about your site's posts, pages, comments, categories, and other content. --> <!-- You may use this file to transfer that content from one site to another. --> <!-- This file is not intended to serve as a complete backup of your site. --> <!-- To import this information into a WordPress site follow these steps: --> <!-- 1. Log in to that site as an administrator. --> <!-- 2. Go to Tools: Import in the WordPress admin panel. --> <!-- 3. Install the "WordPress" importer from the list. --> <!-- 4. Activate & Run Importer. --> <!-- 5. Upload this file using the form provided on that page. --> <!-- 6. You will first be asked to map the authors in this export file to users --> <!-- on the site. For each author, you may choose to map to an --> <!-- existing user on the site or to create a new user. --> <!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. --> <!-- contained in this file into your site. --> <?php the_generator('export'); ?> <rss version="2.0" xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?> /excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?> /" > <channel> <title><?php bloginfo_rss('name'); ?> </title> <link><?php bloginfo_rss('url'); ?> </link> <description><?php bloginfo_rss('description'); ?> </description> <pubDate><?php echo date('D, d M Y H:i:s +0000'); ?> </pubDate> <language><?php bloginfo_rss('language'); ?> </language> <wp:wxr_version><?php echo WXR_VERSION; ?> </wp:wxr_version> <wp:base_site_url><?php echo wxr_site_url(); ?> </wp:base_site_url> <wp:base_blog_url><?php bloginfo_rss('url'); ?> </wp:base_blog_url> <?php wxr_authors_list(); ?> <?php foreach ($cats as $c) { ?> <wp:category><wp:term_id><?php echo wp_kses_post($c->term_id); ?> </wp:term_id><wp:category_nicename><?php echo esc_html($c->slug); ?> </wp:category_nicename><wp:category_parent><?php if ($c->parent) { echo esc_html($cats[$c->parent]->slug); } ?> </wp:category_parent><?php wxr_cat_name($c); wxr_category_description($c); ?> </wp:category> <?php } foreach ($tags as $t) { ?> <wp:tag><wp:term_id><?php echo esc_html($t->term_id); ?> </wp:term_id><wp:tag_slug><?php echo esc_html($t->slug); ?> </wp:tag_slug><?php wxr_tag_name($t); wxr_tag_description($t); ?> </wp:tag> <?php } foreach ($terms as $t) { ?> <wp:term><wp:term_id><?php echo esc_html($t->term_id); ?> </wp:term_id><wp:term_taxonomy><?php echo esc_html($t->taxonomy); ?> </wp:term_taxonomy><wp:term_slug><?php echo esc_html($t->slug); ?> </wp:term_slug><wp:term_parent><?php if ($t->parent) { echo esc_html($terms[$t->parent]->slug); } ?> </wp:term_parent><?php wxr_term_name($t); wxr_term_description($t); ?> </wp:term> <?php } if ('all' == $args['content']) { wxr_nav_menu_terms(); } ?> <?php do_action('rss2_head'); ?> <?php if ($post_ids) { global $wp_query; $wp_query->in_the_loop = true; // Fake being in the loop. // fetch 20 posts at a time rather than loading the entire table into memory while ($next_posts = array_splice($post_ids, 0, 20)) { $where = 'WHERE ID IN (' . join(',', $next_posts) . ')'; $posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} {$where}"); // Begin Loop foreach ($posts as $post) { setup_postdata($post); $is_sticky = is_sticky($post->ID) ? 1 : 0; ?> <item> <?php /** This filter is documented in wp-includes/feed.php */ $post_title = $post->post_title; $post_name = $post->post_name; $media_url = wp_get_attachment_url($post->ID); $post_guid = get_the_guid(); $post_meta_key = ''; if ($post->post_type == 'attachment') { if (strpos($post->post_mime_type, 'image/') !== false && $post->post_mime_type !== 'image/url' && strpos($post_guid, 'undsgn.com') !== false) { $random_value = rand(); $post_title = 'Demo media ' . $random_value; $post_name = 'demo-media-' . $random_value; $upload_dir = wp_upload_dir(); if (strpos($media_url, 'product-') !== false) { $media_name = 'product-placeholder.jpg'; } else { $media_name = 'photo-placeholder-' . rand(1, 20) . '.jpg'; } $media_url = 'http://static.undsgn.com/uncode/dummy_placeholders/' . $media_name; $post_guid = 'http://static.undsgn.com/uncode/dummy_placeholders/' . $media_name; $post_meta_key = trailingslashit(ltrim($upload_dir['subdir'], '/')) . $media_name; } } ?> <title><?php echo apply_filters('the_title_rss', $post_title); ?> </title> <link><?php the_permalink_rss(); ?> </link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?> </pubDate> <dc:creator><?php echo wxr_cdata(get_the_author_meta('login')); ?> </dc:creator> <guid isPermaLink="false"><?php echo esc_url($post_guid); ?> </guid> <description></description> <content:encoded><?php echo wxr_cdata(apply_filters('the_content_export', $post->post_content)); ?> </content:encoded> <excerpt:encoded><?php echo wxr_cdata(apply_filters('the_excerpt_export', $post->post_excerpt)); ?> </excerpt:encoded> <wp:post_id><?php echo esc_html($post->ID); ?> </wp:post_id> <wp:post_date><?php echo esc_html($post->post_date); ?> </wp:post_date> <wp:post_date_gmt><?php echo esc_html($post->post_date_gmt); ?> </wp:post_date_gmt> <wp:comment_status><?php echo esc_html($post->comment_status); ?> </wp:comment_status> <wp:ping_status><?php echo esc_html($post->ping_status); ?> </wp:ping_status> <wp:post_name><?php echo esc_html($post_name); ?> </wp:post_name> <wp:status><?php echo esc_html($post->post_status); ?> </wp:status> <wp:post_parent><?php echo esc_html($post->post_parent); ?> </wp:post_parent> <wp:menu_order><?php echo esc_html($post->menu_order); ?> </wp:menu_order> <wp:post_type><?php echo esc_html($post->post_type); ?> </wp:post_type> <wp:post_password><?php echo esc_html($post->post_password); ?> </wp:post_password> <wp:is_sticky><?php echo esC_html($is_sticky); ?> </wp:is_sticky> <?php if ($post->post_type == 'attachment') { ?> <wp:attachment_url><?php echo esc_url($media_url); ?> </wp:attachment_url> <wp:post_mime_type><?php echo esc_html($post->post_mime_type); ?> </wp:post_mime_type> <?php } wxr_post_taxonomy(); $postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE post_id = %d", $post->ID)); foreach ($postmeta as $meta) { if (apply_filters('wxr_export_skip_postmeta', false, $meta->meta_key, $meta)) { continue; } if ('_wp_attached_file' === $meta->meta_key && $post_meta_key !== '') { $post_meta_value = $post_meta_key; } else { $post_meta_value = $meta->meta_value; } ?> <wp:postmeta> <wp:meta_key><?php echo esc_html($meta->meta_key); ?> </wp:meta_key> <wp:meta_value><?php echo wxr_cdata($post_meta_value); ?> </wp:meta_value> </wp:postmeta> <?php } $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID)); foreach ($comments as $c) { ?> <wp:comment> <wp:comment_id><?php echo esc_html($c->comment_ID); ?> </wp:comment_id> <wp:comment_author><?php echo wxr_cdata(wp_kses_post($c->comment_author)); ?> </wp:comment_author> <wp:comment_author_email><?php echo esc_html($c->comment_author_email); ?> </wp:comment_author_email> <wp:comment_author_url><?php echo esc_url_raw($c->comment_author_url); ?> </wp:comment_author_url> <wp:comment_author_IP><?php echo esc_html($c->comment_author_IP); ?> </wp:comment_author_IP> <wp:comment_date><?php echo esc_html($c->comment_date); ?> </wp:comment_date> <wp:comment_date_gmt><?php echo esc_html($c->comment_date_gmt); ?> </wp:comment_date_gmt> <wp:comment_content><?php echo wxr_cdata(wp_kses_post($c->comment_content)); ?> </wp:comment_content> <wp:comment_approved><?php echo esc_html($c->comment_approved); ?> </wp:comment_approved> <wp:comment_type><?php echo esc_html($c->comment_type); ?> </wp:comment_type> <wp:comment_parent><?php echo esc_html($c->comment_parent); ?> </wp:comment_parent> <wp:comment_user_id><?php echo esc_html($c->user_id); ?> </wp:comment_user_id> <?php $c_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->commentmeta} WHERE comment_id = %d", $c->comment_ID)); foreach ($c_meta as $meta) { ?> <wp:commentmeta> <wp:meta_key><?php echo esc_html($meta->meta_key); ?> </wp:meta_key> <wp:meta_value><?php echo wxr_cdata(wp_kses_post($meta->meta_value)); ?> </wp:meta_value> </wp:commentmeta> <?php } ?> </wp:comment> <?php } ?> </item> <?php } } } ?> </channel> </rss> <?php }
/** * Display the Post Global Unique Identifier (guid). * * The guid will appear to be a link, but should not be used as an link to the * post. The reason you should not use it as a link, is because of moving the * blog across domains. * * Url is escaped to make it xml safe * * @since 1.5.0 * * @param int|WP_Post $id Optional. Post ID or post object. */ function the_guid($id = 0) { /** * Filter the escaped Global Unique Identifier (guid) of the post. * * @since 4.2.0 * * @see get_the_guid() * * @param string $post_guid Escaped Global Unique Identifier (guid) of the post. */ echo apply_filters('the_guid', get_the_guid($id)); }
/** * Generates the WXR export file for download * * @since 2.1.0 * * @param array $args Filters defining what should be included in the export */ function zn_export_wp($args = array()) { global $wpdb, $post; $defaults = array('replace_images' => !empty($_POST['replace_images']), 'content' => 'all', 'author' => false, 'category' => false, 'start_date' => false, 'end_date' => false, 'status' => false); $args = wp_parse_args($args, $defaults); $ids = array(); // BUILD POST ID'S $all_post_types = get_post_types(); // BUILD THE QUERY FOR POSTS $where = "1=1"; foreach ($all_post_types as $key => $value) { if (!empty($_POST['zn_' . $value])) { $ids = array_merge($ids, $_POST['zn_' . $value]); } } if (!empty($ids)) { $where .= " AND {$wpdb->posts}.ID IN (" . implode(',', $ids) . ')'; } $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'"; $join = ''; // grab a snapshot of post IDs, just in case it changes during the export $post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} {$join} WHERE {$where} ORDER BY ID "); // get the requested terms ready, empty unless posts filtered by category or all content $cats = $tags = $terms = array(); if (isset($term) && $term) { $cat = get_term($term['term_id'], 'category'); $cats = array($cat->term_id => $cat); unset($term, $cat); } else { if ('all' == $args['content']) { $categories = (array) get_categories(array('get' => 'all')); $tags = (array) get_tags(array('get' => 'all')); $custom_taxonomies = get_taxonomies(array('_builtin' => false)); $custom_terms = (array) get_terms($custom_taxonomies, array('get' => 'all')); // put categories in order with no child going before its parent while ($cat = array_shift($categories)) { if ($cat->parent == 0 || isset($cats[$cat->parent])) { $cats[$cat->term_id] = $cat; } else { $categories[] = $cat; } } // put terms in order with no child going before its parent while ($t = array_shift($custom_terms)) { if ($t->parent == 0 || isset($terms[$t->parent])) { $terms[$t->term_id] = $t; } else { $custom_terms[] = $t; } } unset($categories, $custom_taxonomies, $custom_terms); } } /** * Wrap given string in XML CDATA tag. * * @since 2.1.0 * * @param string $str String to wrap in XML CDATA tag. * @return string */ function zn_wxr_cdata($str) { if (seems_utf8($str) == false) { $str = utf8_encode($str); } // $str = ent2ncr(esc_html($str)); $str = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $str) . ']]>'; return $str; } /** * Return the URL of the site * * @since 2.5.0 * * @return string Site URL. */ function zn_wxr_site_url() { // ms: the base url if (is_multisite()) { return network_home_url(); } else { return get_bloginfo_rss('url'); } } /** * Output a cat_name XML tag from a given category object * * @since 2.1.0 * * @param object $category Category Object */ function zn_wxr_cat_name($category) { if (empty($category->name)) { return; } echo '<wp:cat_name>' . zn_wxr_cdata($category->name) . '</wp:cat_name>'; } /** * Output a category_description XML tag from a given category object * * @since 2.1.0 * * @param object $category Category Object */ function zn_wxr_category_description($category) { if (empty($category->description)) { return; } echo '<wp:category_description>' . zn_wxr_cdata($category->description) . '</wp:category_description>'; } /** * Output a tag_name XML tag from a given tag object * * @since 2.3.0 * * @param object $tag Tag Object */ function zn_wxr_tag_name($tag) { if (empty($tag->name)) { return; } echo '<wp:tag_name>' . zn_wxr_cdata($tag->name) . '</wp:tag_name>'; } /** * Output a tag_description XML tag from a given tag object * * @since 2.3.0 * * @param object $tag Tag Object */ function zn_wxr_tag_description($tag) { if (empty($tag->description)) { return; } echo '<wp:tag_description>' . zn_wxr_cdata($tag->description) . '</wp:tag_description>'; } /** * Output a term_name XML tag from a given term object * * @since 2.9.0 * * @param object $term Term Object */ function zn_wxr_term_name($term) { if (empty($term->name)) { return; } echo '<wp:term_name>' . zn_wxr_cdata($term->name) . '</wp:term_name>'; } /** * Output a term_description XML tag from a given term object * * @since 2.9.0 * * @param object $term Term Object */ function zn_wxr_term_description($term) { if (empty($term->description)) { return; } echo '<wp:term_description>' . zn_wxr_cdata($term->description) . '</wp:term_description>'; } /** * Output list of authors with posts * * @since 3.1.0 */ function zn_wxr_authors_list() { global $wpdb; $authors = array(); $results = $wpdb->get_results("SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_status != 'auto-draft'"); foreach ((array) $results as $result) { $authors[] = get_userdata($result->post_author); } $authors = array_filter($authors); foreach ($authors as $author) { echo "\t<wp:author>"; echo '<wp:author_id>' . $author->ID . '</wp:author_id>'; echo '<wp:author_login>' . $author->user_login . '</wp:author_login>'; echo '<wp:author_email>' . $author->user_email . '</wp:author_email>'; echo '<wp:author_display_name>' . zn_wxr_cdata($author->display_name) . '</wp:author_display_name>'; echo '<wp:author_first_name>' . zn_wxr_cdata($author->user_firstname) . '</wp:author_first_name>'; echo '<wp:author_last_name>' . zn_wxr_cdata($author->user_lastname) . '</wp:author_last_name>'; echo "</wp:author>\n"; } } /** * Ouput all navigation menu terms * * @since 3.1.0 */ function zn_wxr_nav_menu_terms() { $nav_menus = wp_get_nav_menus(); if (empty($nav_menus) || !is_array($nav_menus)) { return; } foreach ($nav_menus as $menu) { echo "\t<wp:term><wp:term_id>{$menu->term_id}</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>{$menu->slug}</wp:term_slug>"; zn_wxr_term_name($menu); echo "</wp:term>\n"; } } /** * Output list of taxonomy terms, in XML tag format, associated with a post * * @since 2.3.0 */ function zn_wxr_post_taxonomy() { $post = get_post(); $taxonomies = get_object_taxonomies($post->post_type); if (empty($taxonomies)) { return; } $terms = wp_get_object_terms($post->ID, $taxonomies); foreach ((array) $terms as $term) { echo "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . zn_wxr_cdata($term->name) . "</category>\n"; } } function zn_wxr_filter_postmeta($return_me, $meta_key) { if ('_edit_lock' == $meta_key) { $return_me = true; } return $return_me; } add_filter('wxr_export_skip_postmeta', 'zn_wxr_filter_postmeta', 10, 2); echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n"; //print_z( $post_ids ); ?> <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. --> <!-- It contains information about your site's posts, pages, comments, categories, and other content. --> <!-- You may use this file to transfer that content from one site to another. --> <!-- This file is not intended to serve as a complete backup of your site. --> <!-- To import this information into a WordPress site follow these steps: --> <!-- 1. Log in to that site as an administrator. --> <!-- 2. Go to Tools: Import in the WordPress admin panel. --> <!-- 3. Install the "WordPress" importer from the list. --> <!-- 4. Activate & Run Importer. --> <!-- 5. Upload this file using the form provided on that page. --> <!-- 6. You will first be asked to map the authors in this export file to users --> <!-- on the site. For each author, you may choose to map to an --> <!-- existing user on the site or to create a new user. --> <!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. --> <!-- contained in this file into your site. --> <?php the_generator('export'); ?> <rss version="2.0" xmlns:excerpt="http://wordpress.org/export/<?php echo ZN_WXR_VERSION; ?> /excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/<?php echo ZN_WXR_VERSION; ?> /" > <channel> <title><?php bloginfo_rss('name'); ?> </title> <link><?php bloginfo_rss('url'); ?> </link> <description><?php bloginfo_rss('description'); ?> </description> <pubDate><?php echo date('D, d M Y H:i:s +0000'); ?> </pubDate> <language><?php bloginfo_rss('language'); ?> </language> <wp:wxr_version><?php echo ZN_WXR_VERSION; ?> </wp:wxr_version> <wp:base_site_url><?php echo zn_wxr_site_url(); ?> </wp:base_site_url> <wp:base_blog_url><?php bloginfo_rss('url'); ?> </wp:base_blog_url> <?php zn_wxr_authors_list(); ?> <?php foreach ($cats as $c) { ?> <wp:category><wp:term_id><?php echo $c->term_id; ?> </wp:term_id><wp:category_nicename><?php echo $c->slug; ?> </wp:category_nicename><wp:category_parent><?php echo $c->parent ? $cats[$c->parent]->slug : ''; ?> </wp:category_parent><?php zn_wxr_cat_name($c); zn_wxr_category_description($c); ?> </wp:category> <?php } foreach ($tags as $t) { ?> <wp:tag><wp:term_id><?php echo $t->term_id; ?> </wp:term_id><wp:tag_slug><?php echo $t->slug; ?> </wp:tag_slug><?php zn_wxr_tag_name($t); zn_wxr_tag_description($t); ?> </wp:tag> <?php } foreach ($terms as $t) { ?> <wp:term><wp:term_id><?php echo $t->term_id; ?> </wp:term_id><wp:term_taxonomy><?php echo $t->taxonomy; ?> </wp:term_taxonomy><wp:term_slug><?php echo $t->slug; ?> </wp:term_slug><wp:term_parent><?php echo $t->parent ? $terms[$t->parent]->slug : ''; ?> </wp:term_parent><?php zn_wxr_term_name($t); zn_wxr_term_description($t); ?> </wp:term> <?php } if ('all' == $args['content']) { zn_wxr_nav_menu_terms(); } ?> <?php /** This action is documented in wp-includes/feed-rss2.php */ do_action('rss2_head'); ?> <?php if ($post_ids) { global $wp_query; $wp_query->in_the_loop = true; // Fake being in the loop. // fetch 20 posts at a time rather than loading the entire table into memory while ($next_posts = array_splice($post_ids, 0, 20)) { $where = 'WHERE ID IN (' . join(',', $next_posts) . ')'; $posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} {$where}"); // Begin Loop foreach ($posts as $post) { setup_postdata($post); $is_sticky = is_sticky($post->ID) ? 1 : 0; ?> <item> <?php /** This filter is documented in wp-includes/feed.php */ ?> <title><?php echo apply_filters('the_title_rss', $post->post_title); ?> </title> <link><?php the_permalink_rss(); ?> </link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?> </pubDate> <dc:creator><?php echo zn_wxr_cdata(get_the_author_meta('login')); ?> </dc:creator> <guid isPermaLink="false"><?php if ($post->post_type == 'attachment' && !empty($args['replace_images'])) { echo str_replace('wp-content/uploads/', 'zn-content/uploads/', esc_url(get_the_guid())); } else { the_guid(); } ?> </guid> <description></description> <content:encoded><?php /** * Filter the post content used for WXR exports. * * @since 2.5.0 * * @param string $post_content Content of the current post. */ echo zn_wxr_cdata(apply_filters('the_content_export', $post->post_content)); ?> </content:encoded> <excerpt:encoded><?php /** * Filter the post excerpt used for WXR exports. * * @since 2.6.0 * * @param string $post_excerpt Excerpt for the current post. */ echo zn_wxr_cdata(apply_filters('the_excerpt_export', $post->post_excerpt)); ?> </excerpt:encoded> <wp:post_id><?php echo $post->ID; ?> </wp:post_id> <wp:post_date><?php echo $post->post_date; ?> </wp:post_date> <wp:post_date_gmt><?php echo $post->post_date_gmt; ?> </wp:post_date_gmt> <wp:comment_status><?php echo $post->comment_status; ?> </wp:comment_status> <wp:ping_status><?php echo $post->ping_status; ?> </wp:ping_status> <wp:post_name><?php echo $post->post_name; ?> </wp:post_name> <wp:status><?php echo $post->post_status; ?> </wp:status> <wp:post_parent><?php echo $post->post_parent; ?> </wp:post_parent> <wp:menu_order><?php echo $post->menu_order; ?> </wp:menu_order> <wp:post_type><?php echo $post->post_type; ?> </wp:post_type> <wp:post_password><?php echo $post->post_password; ?> </wp:post_password> <wp:is_sticky><?php echo $is_sticky; ?> </wp:is_sticky> <?php if ($post->post_type == 'attachment') { ?> <wp:attachment_url><?php if (!empty($args['replace_images'])) { echo str_replace('wp-content/uploads/', 'zn-content/uploads/', wp_get_attachment_url($post->ID)); } else { echo wp_get_attachment_url($post->ID); } ?> </wp:attachment_url> <?php } zn_wxr_post_taxonomy(); $postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE post_id = %d", $post->ID)); foreach ($postmeta as $meta) { /** * Filter whether to selectively skip post meta used for WXR exports. * * Returning a truthy value to the filter will skip the current meta * object from being exported. * * @since 3.3.0 * * @param bool $skip Whether to skip the current post meta. Default false. * @param string $meta_key Current meta key. * @param object $meta Current meta object. */ if (apply_filters('wxr_export_skip_postmeta', false, $meta->meta_key, $meta)) { continue; } // ZN CHANGE META VALUE FOR THUMBNAIL_ID // if ( $meta->meta_key == '_thumbnail_id' ) { // $meta->meta_value = str_replace( 'wp-content/uploads/' , 'zn-content/uploads/', $meta->meta_value ); // } // REPLACE THE IMAGE URLS IF PERMITTED if (!empty($args['replace_images'])) { $meta->meta_value = str_replace('wp-content/uploads/', 'zn-content/uploads/', $meta->meta_value); } ?> <wp:postmeta> <wp:meta_key><?php echo $meta->meta_key; ?> </wp:meta_key> <wp:meta_value><?php echo zn_wxr_cdata($meta->meta_value); ?> </wp:meta_value> </wp:postmeta> <?php } $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID)); foreach ($comments as $c) { ?> <wp:comment> <wp:comment_id><?php echo $c->comment_ID; ?> </wp:comment_id> <wp:comment_author><?php echo zn_wxr_cdata($c->comment_author); ?> </wp:comment_author> <wp:comment_author_email><?php echo $c->comment_author_email; ?> </wp:comment_author_email> <wp:comment_author_url><?php echo esc_url_raw($c->comment_author_url); ?> </wp:comment_author_url> <wp:comment_author_IP><?php echo $c->comment_author_IP; ?> </wp:comment_author_IP> <wp:comment_date><?php echo $c->comment_date; ?> </wp:comment_date> <wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?> </wp:comment_date_gmt> <wp:comment_content><?php echo zn_wxr_cdata($c->comment_content); ?> </wp:comment_content> <wp:comment_approved><?php echo $c->comment_approved; ?> </wp:comment_approved> <wp:comment_type><?php echo $c->comment_type; ?> </wp:comment_type> <wp:comment_parent><?php echo $c->comment_parent; ?> </wp:comment_parent> <wp:comment_user_id><?php echo $c->user_id; ?> </wp:comment_user_id> <?php $c_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->commentmeta} WHERE comment_id = %d", $c->comment_ID)); foreach ($c_meta as $meta) { ?> <wp:commentmeta> <wp:meta_key><?php echo $meta->meta_key; ?> </wp:meta_key> <wp:meta_value><?php echo zn_wxr_cdata($meta->meta_value); ?> </wp:meta_value> </wp:commentmeta> <?php } ?> </wp:comment> <?php } ?> </item> <?php } } } ?> </channel> </rss> <?php }
/** * Display the Post Global Unique Identifier (guid). * * The guid will appear to be a link, but should not be used as an link to the * post. The reason you should not use it as a link, is because of moving the * blog across domains. * * Url is escaped to make it xml safe * * @since 1.5.0 * * @param int $id Optional. Post ID. */ function the_guid($id = 0) { echo esc_url(get_the_guid($id)); }
/** * * Ceate an attachment for images and return image tag or gallery shortcode to be rendered in the editor */ public static function write_upload() { global $content_width; $_POST['action'] = 'wp_handle_upload'; $images = array(); $files = array(); $videos = array(); $errors = array(); $output = ''; for ($i = 0; $i < $_POST['num_files']; $i++) { // Create attachment for the image. $attachment_id = media_handle_upload("file_{$i}", 0); if (is_wp_error($attachment_id)) { do_action('o2_error', 'o2_image_upload'); $error = array($_FILES["file_{$i}"]['name'], $attachment_id->get_error_message()); array_push($errors, $error); } else { $type = wp_check_filetype($_FILES["file_{$i}"]['name']); if (wp_attachment_is_image($attachment_id)) { // If it's an image, add it to the image stack array_push($images, $attachment_id); } else { if (0 === strpos($type['type'], 'video')) { array_push($videos, $attachment_id); } else { // Otherwise add it to a list of files that we'll just link to directly array_push($files, $attachment_id); } } } } // Known upload errors (@todo allow partial success, send errors in response payload) if (count($errors)) { self::die_failure('upload_failed_errors', $errors); } // Nothing successfully uploaded if (0 == count($images) + count($files) + count($videos)) { self::die_failure('no_valid_uploads', __('Your upload failed. Perhaps try from within wp-admin.', 'o2')); } switch (count($images)) { default: // return multiple images as a gallery shortcode $output .= '[gallery ids="' . esc_attr(implode(',', $images)) . '"]' . "\n"; break; case 1: // return single image as html element $image_id = $images[0]; // Get the image $image_src = $image_src_w = get_the_guid($image_id); $image_dims = wp_get_attachment_image_src($image_id, 'full'); // if the image is NOT an animated gif, append the image_width to the src if (!self::is_animated_gif(get_attached_file($image_id)) && !empty($content_width)) { $image_src_w = $image_src . '?w=' . $content_width; } $output .= '<a href="' . esc_attr($image_src) . '"><img src="' . esc_attr($image_src_w) . '" alt="' . esc_attr(get_the_title($image_id)) . '" class="size-full wp-image" id="i-' . esc_attr($image_id) . '" /></a>' . "\n"; break; case 0: break; // catch this so that it doesn't do a gallery (default) } // Add embed shortcodes for uploaded videos $video_output = ''; foreach ((array) $videos as $video) { $video_output .= '[video src=' . esc_url(wp_get_attachment_url($video)) . "]\n"; } $output .= apply_filters('o2_video_attachment', $video_output, $videos); // Add links to each file on a line of their own foreach ((array) $files as $file) { $output .= '<a href="' . esc_url(wp_get_attachment_url($file)) . '" id="i-' . esc_attr($image_id) . '">' . get_the_title($file) . '</a>' . "\n"; } self::die_success($output); exit; }
/** * Display the Post Global Unique Identifier (guid). * * The guid will appear to be a link, but should not be used as a link to the * post. The reason you should not use it as a link, is because of moving the * blog across domains. * * URL is escaped to make it XML-safe. * * @since 1.5.0 * * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post. */ function the_guid($post = 0) { $post = get_post($post); $guid = isset($post->guid) ? get_the_guid($post) : ''; $id = isset($post->ID) ? $post->ID : 0; /** * Filters the escaped Global Unique Identifier (guid) of the post. * * @since 4.2.0 * * @see get_the_guid() * * @param string $guid Escaped Global Unique Identifier (guid) of the post. * @param int $id The post ID. */ echo apply_filters('the_guid', $guid, $id); }
/** * Get Subpages */ function get_child_pages() { global $post; $output = ''; $query = new WP_Query(array('post_parent' => $post->ID, 'post_type' => 'page', 'order' => 'ASC', 'orderby' => 'menu_order', 'posts_per_page' => -1)); if ($query->have_posts()) { $cnt = 0; while ($query->have_posts()) { $query->the_post(); if ($cnt == 6) { $style = 'style="margin-left:0"'; } elseif ($cnt == 2) { $style = 'style="margin-left:0; clear: both"'; } else { $style = ''; } $output .= '<div class="child-page-link" ' . $style . ' id="child-page-' . get_the_ID() . '"><a class="fancybox" href="' . get_the_guid() . '&ajax=true">' . get_the_title() . '</a></div>'; $cnt++; $style = ''; } return '<div id="child-pages">' . $output . '</div>'; } else { return false; } }
/** * Hook for managing future post transitions to published. * * @since 2.3.0 * @access private * @uses $wpdb * @uses do_action() Calls 'private_to_published' on post ID if this is a 'private_to_published' call. * @uses wp_clear_scheduled_hook() with 'publish_future_post' and post ID. * * @param string $new_status New post status * @param string $old_status Previous post status * @param object $post Object type containing the post information */ function _transition_post_status($new_status, $old_status, $post) { global $wpdb; if ($old_status != 'publish' && $new_status == 'publish') { // Reset GUID if transitioning to publish and it is empty if ('' == get_the_guid($post->ID)) { $wpdb->update($wpdb->posts, array('guid' => get_permalink($post->ID)), array('ID' => $post->ID)); } do_action('private_to_published', $post->ID); // Deprecated, use private_to_publish } // If published posts changed clear the lastpostmodified cache if ('publish' == $new_status || 'publish' == $old_status) { foreach (array('server', 'gmt', 'blog') as $timezone) { wp_cache_delete("lastpostmodified:{$timezone}", 'timeinfo'); wp_cache_delete("lastpostdate:{$timezone}", 'timeinfo'); } } // Always clears the hook in case the post status bounced from future to draft. wp_clear_scheduled_hook('publish_future_post', array($post->ID)); }
function wp_get_attachment_url( $post_id = 0 ) { $post_id = (int) $post_id; if ( !$post =& get_post( $post_id ) ) return false; $url = get_the_guid( $post->ID ); if ( 'attachment' != $post->post_type || !$url ) return false; return apply_filters( 'wp_get_attachment_url', $url, $post->ID ); }