function mt_getpost($params) { // ($postid, $user, $pass) $xpostid = $params->getParam(0); $xuser = $params->getParam(1); $xpass = $params->getParam(2); $post_ID = $xpostid->scalarval(); $username = $xuser->scalarval(); $password = $xpass->scalarval(); // Check login if (user_pass_ok(addslashes($username), $password)) { $postdata = get_postdata($post_ID); if ($postdata['Date'] != '') { // why were we converting to GMT here? spec doesn't call for that. //$post_date = mysql2date('U', $postdata['Date']); //$post_date = gmdate('Ymd', $post_date).'T'.gmdate('H:i:s', $post_date); $post_date = strtotime($postdata['Date']); $post_date = date('Ymd', $post_date) . 'T' . date('H:i:s', $post_date); $catids = wp_get_post_cats('1', $post_ID); logIO('O', 'Category No:' . count($catids)); foreach ($catids as $catid) { $catname = get_cat_name($catid); logIO('O', 'Category:' . $catname); $catnameenc = new xmlrpcval(mb_conv($catname, 'UTF-8', $GLOBALS['blog_charset'])); $catlist[] = $catnameenc; } $post = get_extended($postdata['Content']); $allow_comments = 'open' == $postdata['comment_status'] ? 1 : 0; $allow_pings = 'open' == $postdata['ping_status'] ? 1 : 0; $resp = array('link' => new xmlrpcval(post_permalink($post_ID)), 'title' => new xmlrpcval(mb_conv($postdata['Title'], 'UTF-8', $GLOBALS['blog_charset'])), 'description' => new xmlrpcval(mb_conv($post['main'], 'UTF-8', $GLOBALS['blog_charset'])), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'userid' => new xmlrpcval($postdata['Author_ID']), 'postid' => new xmlrpcval($postdata['ID']), 'content' => new xmlrpcval(mb_conv($postdata['Content'], 'UTF-8', $GLOBALS['blog_charset'])), 'permalink' => new xmlrpcval(post_permalink($post_ID)), 'categories' => new xmlrpcval($catlist, 'array'), 'mt_keywords' => new xmlrpcval("{$catids[0]}"), 'mt_excerpt' => new xmlrpcval(mb_conv($postdata['Excerpt'], 'UTF-8', $GLOBALS['blog_charset'])), 'mt_allow_comments' => new xmlrpcval($allow_comments, 'int'), 'mt_allow_pings' => new xmlrpcval($allow_pings, 'int'), 'mt_convert_breaks' => new xmlrpcval('true'), 'mt_text_more' => new xmlrpcval(mb_conv($post['extended'], 'UTF-8', $GLOBALS['blog_charset']))); $resp = new xmlrpcval($resp, 'struct'); return new xmlrpcresp($resp); } else { return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 3, "No such post #{$post_ID}"); } } else { return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password)); } }
/** * Append the extended contents to the "read more" link * * @param string $link The current "read more" link * @param string $linkText The text for the "read more" link * * @return string "Read more" link with the extended entry contents */ public function appendExtended($link, $linkText) { $link = $this->replaceLinkText($link, $linkText); $post = get_post(); $extended = get_extended($post->post_content); $extended = "<div class=\"entry-extended\">{$extended['extended']}</div>"; return $link . $extended; }
/** * @see CPAC_Column::get_raw_value() * @since 2.0.3 */ function get_raw_value($post_id) { $value = ''; $p = get_post($post_id); $extended = get_extended($p->post_content); if (!empty($extended['extended'])) { $value = $this->get_shortened_string($extended['main'], $this->options->excerpt_length); } return $value; }
function toutatis_excerpt($length) { global $post; // No excerpt needed if ($length == 0) { return ''; } // Do we have an excerpt ? (excerpt field in the post editor) if (has_excerpt()) { return apply_filters('the_excerpt', wpautop(strip_shortcodes(strip_tags(get_the_excerpt())))); } // Do we have a read more tag (<!--more-->) in the post content ? if (strpos($post->post_content, '<!--more-->')) { $content_arr = get_extended($post->post_content); return apply_filters('the_excerpt', wpautop(strip_shortcodes(strip_tags($content_arr['main'])))); } // Get the post content without shortcodes or HTML tags $content = strip_shortcodes(strip_tags(get_the_content())); // Create a custom excerpt based on the post content return apply_filters('the_excerpt', wpautop(wp_trim_words($content, $length))); }
function bdn_xmlrpc_get_posts($args) { global $wp_xmlrpc_server; $wp_xmlrpc_server->escape($args); $blog_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $post_type = $args[3]; $category = $args[4]; $numberposts = $args[5]; $extra = $args[6]; if (!($user = $wp_xmlrpc_server->login($username, $password))) { return $wp_xmlrpc_server->error; } $category_int = (int) $category; if (!empty($category_int)) { $category_call = 'cat'; } else { $category_call = 'category_name'; } $post_args = array('numberposts' => $numberposts, 'posts_per_page' => $numberposts, $category_call => $category, 'post_type' => $post_type, 'post_status' => 'any'); if (is_array($extra)) { $post_args = array_merge($post_args, $extra); } $posts_list = query_posts($post_args); if (!$posts_list) { $wp_xmlrpc_server->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); return $wp_xmlrpc_server->error; } foreach ($posts_list as $entry) { if (!current_user_can('edit_post', $entry->ID)) { continue; } $post_date = mysql2date('Ymd\\TH:i:s', $entry->post_date, false); $post_date_gmt = mysql2date('Ymd\\TH:i:s', $entry->post_date_gmt, false); $post_modified = mysql2date('Ymd\\TH:i:s', $entry->post_modified, false); // For drafts use the GMT version of the date if ($entry->post_status == 'draft') { $post_date_gmt = get_gmt_from_date(mysql2date('Y-m-d H:i:s', $entry->post_date), 'Ymd\\TH:i:s'); } $categories = array(); $cats = get_the_category($entry->ID, 'category'); foreach ($cats as $cat) { $categories[] = array('name' => $cat->cat_name, 'parent' => $cat->category_parent); } $publications = array(); $pubs = get_the_terms($entry->ID, 'publication'); foreach ($pubs as $pub) { $publications[] = $pub->name; } $post = get_extended($entry->post_content); $link = post_permalink($entry->ID); // Get the post author info. $authors = (array) get_userdata($entry->post_author); if (function_exists('get_coauthors')) { $authors = get_coauthors($entry->ID); } $allow_comments = 'open' == $entry->comment_status ? 1 : 0; $allow_pings = 'open' == $entry->ping_status ? 1 : 0; // Consider future posts as published if ($entry->post_status === 'future') { $entry->post_status = 'publish'; } $entryPost = array('post_date' => new IXR_Date($post_date), 'post_updated' => new IXR_Date($post_modified), 'userid' => $entry->post_author, 'post_id' => $entry->ID, 'description' => $post['main'], 'post_title' => $entry->post_title, 'link' => $link, 'permaLink' => $link, 'post_parent' => strval($post['post_parent']), 'post_content' => $entry->post_content, 'categories' => $categories, 'mt_excerpt' => $entry->post_excerpt, 'mt_text_more' => $post['extended'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'wp_slug' => $entry->post_name, 'wp_password' => $entry->post_password, 'wp_authors' => $authors, 'date_created_gmt' => new IXR_Date($post_date_gmt), 'post_status' => $entry->post_status, 'custom_fields' => $wp_xmlrpc_server->get_custom_fields($entry->ID), 'publications' => $publications); $post_type_taxonomies = get_object_taxonomies(POST_TYPE, 'names'); $terms = wp_get_object_terms($entry->ID, $post_type_taxonomies); $entryPost['terms'] = array(); foreach ($terms as $term) { $entryPost['terms'][] = _prepare_term($term); } $struct[] = $entryPost; } $recent_posts = array(); for ($j = 0; $j < count($struct); $j++) { array_push($recent_posts, $struct[$j]); } return $recent_posts; }
/** * Check that content has <!--more--> tag or not :) * * @param $contents * * @return bool */ function hippo_has_more_content($contents) { $contents = get_extended($contents); return !empty($contents['extended']); }
function mltlngg_the_content_filter($content) { global $hook_suffix, $post, $wpdb, $mltlngg_table_translate, $mltlngg_current_language, $mltlngg_active_language, $mltlngg_options, $mltlngg_wp_providers; if (is_admin() && !('post.php' == $hook_suffix || 'post-new.php' == $hook_suffix)) { return $content; } $mltlngg_post_type = get_post_type($post->ID); /* If current post type enabled to translation */ if ($mltlngg_post_type == 'post' || $mltlngg_post_type == 'page') { if (is_admin()) { $mltlngg_current_language = isset($_GET['lang']) ? $_GET['lang'] : (isset($mltlngg_active_language['locale']) ? $mltlngg_active_language['locale'] : $mltlngg_options['default_language']); } $new_content = $wpdb->get_var($wpdb->prepare("SELECT `post_content` FROM {$mltlngg_table_translate} WHERE `post_ID` = %d AND `language` = '%s' ", $post->ID, $mltlngg_current_language)); if (!empty($new_content)) { if (!is_admin()) { if (!post_password_required()) { $noteaser = false !== strpos($new_content, '<!--noteaser-->') ? true : false; $extends = get_extended($new_content); $extended = $extends['extended']; $new_content = $extends['main']; if (!empty($mltlngg_wp_providers)) { foreach ($mltlngg_wp_providers as $template) { if (false !== preg_match($template, $extends['extended'])) { $extended = preg_replace_callback($template, "mltlngg_videos_filter", $extended); } if (false !== preg_match($template, $extends['main'])) { $new_content = preg_replace_callback($template, "mltlngg_videos_filter", $new_content); } } } if (!is_single() && !is_page() && !is_search()) { $more_link_text = __('(more…)'); $more_link = apply_filters('the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">{$more_link_text}</a>", $more_link_text); if ('' != $extended) { $new_content .= $more_link; } } elseif (is_page()) { $new_content .= $extended; } else { if ($noteaser) { $new_content = ''; } $new_content .= 0 != strlen($new_content) ? '<span id="more-' . $post->ID . '"></span>' . $extended : $extended; } if (0 != strlen($new_content)) { return $new_content; } } else { $content = get_the_password_form(); } /* If translation is exist and not empty, filter content */ } else { $content = $new_content; } } } return $content; }
function mw_getRecentPosts($args) { $this->escape($args); $blog_ID = (int) $args[0]; $user_login = $args[1]; $user_pass = $args[2]; $num_posts = (int) $args[3]; if (!$this->login_pass_ok($user_login, $user_pass)) { return $this->error; } $posts_list = wp_get_recent_posts($num_posts); if (!$posts_list) { $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); return $this->error; } set_current_user(0, $user_login); foreach ($posts_list as $entry) { if (!current_user_can('edit_post', $entry['ID'])) { continue; } $post_date = mysql2date('Ymd\\TH:i:s', $entry['post_date']); $post_date_gmt = mysql2date('Ymd\\TH:i:s', $entry['post_date_gmt']); $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach ($catids as $catid) { $categories[] = get_cat_name($catid); } $tagnames = array(); $tags = wp_get_post_tags($entry['ID']); if (!empty($tags)) { foreach ($tags as $tag) { $tagnames[] = $tag->name; } $tagnames = implode(', ', $tagnames); } else { $tagnames = ''; } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); // Get the post author info. $author = get_userdata($entry['post_author']); $allow_comments = 'open' == $entry['comment_status'] ? 1 : 0; $allow_pings = 'open' == $entry['ping_status'] ? 1 : 0; $struct[] = array('dateCreated' => new IXR_Date($post_date), 'userid' => $entry['post_author'], 'postid' => $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], 'wp_author_id' => $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => new IXR_Date($post_date_gmt)); } $recent_posts = array(); for ($j = 0; $j < count($struct); $j++) { array_push($recent_posts, $struct[$j]); } return $recent_posts; }
<div id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <div class="post-quote"> <?php // Fetch post content $content = get_post_field('post_content', get_the_ID()); // Get content parts $content_parts = get_extended($content); // Output part before <!--more--> tag echo $content_parts['main']; ?> </div> <!-- /post-quote --> <?php if (is_sticky()) { ?> <div class="is-sticky"> <div class="genericon genericon-pinned"></div> </div> <?php
function mw_getRecentPosts($args) { $this->escape($args); $blog_ID = $args[0]; $user_login = $args[1]; $user_pass = $args[2]; $num_posts = $args[3]; if (!$this->login_pass_ok($user_login, $user_pass)) { return $this->error; } $posts_list = wp_get_recent_posts($num_posts); if (!$posts_list) { $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.'); return $this->error; } foreach ($posts_list as $entry) { $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']); $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach($catids as $catid) { $categories[] = get_cat_name($catid); } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0; $struct[] = array( 'dateCreated' => new IXR_Date($post_date), 'userid' => $entry['post_author'], 'postid' => $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, // commented out because no other tool seems to use this // 'content' => $entry['post_content'], 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings ); } $recent_posts = array(); for ($j=0; $j<count($struct); $j++) { array_push($recent_posts, $struct[$j]); } return $recent_posts; }
/** * Orderby Posts column * * @since 1.3 */ private function get_orderby_posts_vars($vars) { $post_type = $vars['post_type']; // apply sorting preference $this->apply_sorting_preference($vars, $post_type); // no sorting if (empty($vars['orderby'])) { return $vars; } // Column $column = $this->get_orderby_type($vars['orderby'], $post_type); if (empty($column)) { return $vars; } // id $type = $id = key($column); // Check for taxonomies, such as column-taxonomy-[taxname] if (strpos($type, 'column-taxonomy-') !== false) { $type = 'column-taxonomy'; } // Check for Custom Field if (Codepress_Admin_Columns::is_column_meta($type)) { $type = 'column-post-meta'; } // var $cposts = array(); switch ($type) { case 'column-postid': $vars['orderby'] = 'ID'; break; case 'column-order': $vars['orderby'] = 'menu_order'; break; case 'column-modified': $vars['orderby'] = 'modified'; break; case 'column-comment-count': $vars['orderby'] = 'comment_count'; break; case 'column-post-meta': $field = $column[$id]['field']; // orderby type $field_type = 'meta_value'; if ($column[$id]['field_type'] == 'numeric' || $column[$id]['field_type'] == 'library_id') { $field_type = 'meta_value_num'; } $vars = array_merge($vars, array('meta_key' => $field, 'orderby' => $field_type)); break; case 'column-excerpt': $sort_flag = SORT_STRING; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = $this->prepare_sort_string_value($p->post_content); } break; case 'column-word-count': $sort_flag = SORT_NUMERIC; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = str_word_count(Codepress_Admin_Columns::strip_trim($p->post_content)); } break; case 'column-page-template': $sort_flag = SORT_STRING; $templates = get_page_templates(); foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $page_template = get_post_meta($p->ID, '_wp_page_template', true); $cposts[$p->ID] = array_search($page_template, $templates); } break; case 'column-post_formats': $sort_flag = SORT_REGULAR; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = get_post_format($p->ID); } break; case 'column-attachment': case 'column-attachment-count': $sort_flag = SORT_NUMERIC; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = count(Codepress_Admin_Columns::get_attachment_ids($p->ID)); } break; case 'column-page-slug': $sort_flag = SORT_REGULAR; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = $p->post_name; } break; case 'column-sticky': $sort_flag = SORT_REGULAR; $stickies = get_option('sticky_posts'); foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = $p->ID; if (!empty($stickies) && in_array($p->ID, $stickies)) { $cposts[$p->ID] = 0; } } break; case 'column-featured_image': $sort_flag = SORT_REGULAR; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = $p->ID; $thumb = get_the_post_thumbnail($p->ID); if (!empty($thumb)) { $cposts[$p->ID] = 0; } } break; case 'column-roles': $sort_flag = SORT_STRING; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = 0; $userdata = get_userdata($p->post_author); if (!empty($userdata->roles[0])) { $cposts[$p->ID] = $userdata->roles[0]; } } break; case 'column-status': $sort_flag = SORT_STRING; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = $p->post_status . strtotime($p->post_date); } break; case 'column-comment-status': $sort_flag = SORT_STRING; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = $p->comment_status; } break; case 'column-ping-status': $sort_flag = SORT_STRING; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $cposts[$p->ID] = $p->ping_status; } break; case 'column-taxonomy': $sort_flag = SORT_STRING; // needed to sort $taxonomy = str_replace('column-taxonomy-', '', $id); $cposts = $this->get_posts_sorted_by_taxonomy($post_type, $taxonomy); break; case 'column-author-name': $sort_flag = SORT_STRING; $display_as = $column[$id]['display_as']; if ('userid' == $display_as) { $sort_flag = SORT_NUMERIC; } foreach ($this->get_any_posts_by_posttype($post_type) as $p) { if (!empty($p->post_author)) { $name = Codepress_Admin_Columns::get_author_field_by_nametype($display_as, $p->post_author); $cposts[$p->ID] = $name; } } break; case 'column-before-moretag': $sort_flag = SORT_STRING; foreach ($this->get_any_posts_by_posttype($post_type) as $p) { $extended = get_extended($p->post_content); $content = !empty($extended['extended']) ? $extended['main'] : ''; $cposts[$p->ID] = $this->prepare_sort_string_value($content); } break; /** native WP columns */ // categories /** native WP columns */ // categories case 'categories': $sort_flag = SORT_STRING; // needed to sort $cposts = $this->get_posts_sorted_by_taxonomy($post_type, 'category'); break; // tags // tags case 'tags': $sort_flag = SORT_STRING; // needed to sort $cposts = $this->get_posts_sorted_by_taxonomy($post_type, 'post_tag'); break; } // we will add the sorted post ids to vars['post__in'] and remove unused vars if (isset($sort_flag)) { $vars = $this->get_vars_post__in($vars, $cposts, $sort_flag); } return $vars; }
<?php get_header(); ?> <?php if (have_posts()) { while (have_posts()) { the_post(); ?> <?php $post_content = get_extended($post->post_content); $content_main = apply_filters('the_content', $post_content['main']); $content_extended = apply_filters('the_content', $post_content['extended']); $show_author = get_field('show_author'); //echo '<pre class="debug">';print_r($post_content);echo '</pre>'; if (!empty($post_content['more_text'])) { $more_btn_text = $post_content['more_text']; } else { $more_btn_text = "Continue Reading"; } ?> <!-- Container --> <div class="container"> <article <?php post_class(); ?> >
<?php if ($fields->show_date) { ?> <p><?php echo get_the_time('Y-m-d H:i', $post->ID); ?> </p> <?php } ?> <?php if ($fields->show_excerpt) { ?> <p><?php echo isset(get_extended($post->post_content)['main']) ? get_extended($post->post_content)['main'] : ''; ?> </p> <?php } ?> </div> </a> </div> <?php } ?> </div> <?php }
public function get_extended() { return get_extended($this->post->post_content); }
public function make_excerpt($more_text = null) { // Author inserted a <!--more--> tag $parts = get_extended($this->post_content); if (!empty($parts['extended'])) { $ret = trim($parts['main']); // Conditionally add a read more link and // clean up punctuation and ellipsis at end of excerpt $wc_excerpt = str_word_count($ret); $wc_content = str_word_count($this->post_content); if ($wc_excerpt < $wc_content) { $ret = preg_replace('/([\\.,;:!?\'"]{4,})$/', '...', $ret . '...'); if (!empty($more_text)) { $ret = $ret . ' <a href="' . $this->permalink . '" class="more-link">' . $more_text . '</a>'; } } } // Excerpt is empty, so generate one if (empty($parts['extended'])) { $text = strip_shortcodes($this->post_content); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $excerpt_length = apply_filters('excerpt_length', 55); $read_more = apply_filters('read_more', ' ' . '[...]', $this); $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); if (count($words) > $excerpt_length) { array_pop($words); $text = implode(' ', $words); $text = $text . $read_more; } else { $text = implode(' ', $words); } $ret = apply_filters('wp_trim_excerpt', $text, $raw_excerpt); } /* TODO: cache results of this function */ return $ret; }
function show_single() { global $s, $m, $x, $mtitle, $site_url, $comments, $page_display_name, $site_name, $comment_ok, $date_format, $lang, $error, $scream, $sname, $semail, $scomment, $sweb, $timezone; $rs = safe_row('*', 'pixie_dynamic_posts', "post_slug = '{$x}' and public = 'yes' limit 0,1"); if ($rs) { extract($rs); safe_update('pixie_dynamic_posts', "post_views = {$post_views} + 1", "post_id = '{$post_id}'"); $logunix = returnUnixtimestamp($posted); $date = safe_strftime($date_format, $logunix); $timeunix = returnUnixtimestamp($last_modified); $xdate = safe_strftime($date_format, $timeunix); $microformat = safe_strftime('%Y-%m-%dT%T%z', $logunix); $slug = $post_slug; $fullname = safe_field('realname', 'pixie_users', "user_name='{$author}'"); if (public_page_exists('profiles')) { $mauthor = "<a href=\"" . createURL("profiles", $author) . "\" class=\"url fn\" title=\"" . $lang['view'] . " {$fullname}'s " . $lang['profile'] . "\">{$fullname}</a>"; } else { $mauthor = "<a href=\"{$site_url}\" class=\"url fn\" title=\"{$site_url}\">{$fullname}</a>"; } if (isset($tags) && $tags) { $all_tags = strip_tags($tags); $all_tags = str_replace('"', "", $tags); $tags_array_temp = explode(" ", $all_tags); for ($count = 0; $count < count($tags_array_temp); $count++) { $current = $tags_array_temp[$count]; $first = $current[strlen($current) - strlen($current)]; if ($first == " ") { $current = substr($current, 1, strlen($current) - 1); } $ncurrent = make_slug($current); if (isset($s) && isset($ncurrent)) { if (isset($tag_list)) { } else { $tag_list = NULL; } $tag_list .= "<a href=\"" . createURL($s, 'tag', $ncurrent) . "\" title=\"" . $lang['view'] . " " . $lang['all_posts_tagged'] . ": " . $current . "\" rel=\"tag\" >" . $current . "</a>, "; } if ($ncurrent != "") { if (isset($class_list)) { } else { $class_list = NULL; } $class_list .= "tag_{$ncurrent} "; } } $tag_list = substr($tag_list, 0, strlen($tag_list) - 2) . ""; } if (isset($s)) { $permalink = createURL($s, 'permalink', $slug); } $authorclass = strtolower($author); $timeclass = safe_strftime('y%Y m%m d%d h%H', $logunix); echo "\n\t\t\t\t\t<div class=\"section hentry author_{$authorclass} {$class_list}{$timeclass} single\" id=\"post_{$post_id}\">\n\t\t\t\t\t\t<h4 class=\"entry-title\"><a href=\"{$permalink}\" rel=\"bookmark\">{$title}</a></h4>\n\t\t\t\t\t\t<ul class=\"post_links\">\n\t\t\t\t\t\t\t<li class=\"post_date\"><abbr class=\"published\" title=\"{$microformat}\">{$date}</abbr></li>"; if (isset($_COOKIE['pixie_login'])) { list($username, $cookie_hash) = explode(',', $_COOKIE['pixie_login']); $nonce = safe_field('nonce', 'pixie_users', "user_name='{$username}'"); if (md5($username . $nonce) == $cookie_hash) { $privs = safe_field('privs', 'pixie_users', "user_name='{$username}'"); if ($privs >= 1) { echo "\n\t\t\t\t\t\t\t<li class=\"post_edit\"><a href=\"" . $site_url . "admin/?s=publish&m=dynamic"; if (isset($s)) { echo '&x=' . $s; } echo "&edit={$post_id}\" title=\"" . $lang['edit_post'] . "\">" . $lang['edit_post'] . "</a></li>"; } } } echo "\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t<div class=\"post entry-content\">\n"; //<!--more--> $post = get_extended($content); echo "\t\t\t\t\t\t\t" . $post['main']; if ($post['extended']) { echo $post['extended']; } echo "\n\t\t\t\t\t\t</div>\t\t\n\t\t\t\t\t\t<div class=\"post_credits\">\n\t\t\t\t\t\t \t<span class=\"vcard author\">" . $lang['by'] . " {$mauthor}</span>\n\t\t\t\t\t\t \t<span class=\"post_tags\">" . $lang['tagged'] . ": {$tag_list}</span>\n\t\t\t\t\t\t \t<span class=\"post_updated\">" . $lang['last_updated'] . ": {$xdate} </span>\n\t\t\t\t\t\t</div>\t\t\t\n\t\t\t\t\t</div>\n\t\t\t\t\t\n\t\t\t\t\t<div id=\"nav_posts\" class=\"dynamic_bottom_nav\">\n"; // previous and next posts if (isset($s)) { $thisid = get_page_id($s); } // what post is next? $searchnext = safe_field('post_id', 'pixie_dynamic_posts', "page_id = '{$thisid}' and public = 'yes' and posted > '{$posted}' limit 0,1"); if ($searchnext) { $ntitle = safe_field('title', 'pixie_dynamic_posts', "post_id ='{$searchnext}'"); $nslug = safe_field('post_slug', 'pixie_dynamic_posts', "post_id ='{$searchnext}'"); echo "\t\t\t\t\t\t<div id=\"post_next\" class=\"link_next\"><a class=\"link_next_a\" href=\""; if (isset($s)) { echo createURL($s, 'permalink', $nslug); } echo "\" title=\"" . $lang['next_post'] . ": {$ntitle}\">" . $lang['next_post'] . " »</a></div>\n"; } // what post is previous? $searchprev = safe_field('post_id', 'pixie_dynamic_posts', "page_id = '{$thisid}' and public = 'yes' and posted < '{$posted}' order by posted desc limit 0,1"); if ($searchprev) { $ptitle = safe_field('title', 'pixie_dynamic_posts', "post_id ='{$searchprev}'"); $pslug = safe_field('post_slug', 'pixie_dynamic_posts', "post_id ='{$searchprev}'"); echo "\t\t\t\t\t\t<div id=\"post_previous\" class=\"link_previous\"><a class=\"link_prev_a\" href=\""; if (isset($s)) { echo createURL($s, 'permalink', $pslug); } echo "\" title=\"" . $lang['previous_post'] . ": "; if (isset($ptitle)) { echo $ptitle; } echo "\">« " . $lang['previous_post'] . "</a></div>\n"; } echo "\t\t\t\t\t</div>\n"; $comms = safe_rows('*', 'pixie_module_comments', "post_id = '{$post_id}'"); $no_comms = count($comms); // fix to remove commenting when plug in is removed if (public_page_exists('comments')) { if ($comments == 'yes' or $comms) { echo "\n\t\t\t\t\t<div id=\"comments\">\n\t\t\t\t\t\t<h4 id=\"comments_title\">" . $lang['comments'] . "</h4>"; if (isset($_COOKIE['pixie_login'])) { list($username, $cookie_hash) = explode(',', $_COOKIE['pixie_login']); $nonce = safe_field('nonce', 'pixie_users', "user_name='{$username}'"); if (md5($username . $nonce) == $cookie_hash) { $realname = safe_field('realname', 'pixie_users', "user_name='{$username}'"); $umail = safe_field('email', 'pixie_users', "user_name='{$username}'"); } } $r2 = safe_rows('*', 'pixie_module_comments', "post_id = '{$post_id}' order by posted asc"); if ($r2) { $i = 0; while ($i < $no_comms) { extract($r2[$i]); $default = "{$site_url}files/images/no_grav.jpg"; if (isset($email)) { $grav_url = 'http://www.gravatar.com/avatar.php?gravatar_id=' . md5($email) . '&default=' . urlencode($default) . '&size=40'; } $hash = $i + 1; if ($url) { $namepr = "<span class=\"message_name author\"><a href=\"{$permalink}#comment_{$hash}\" rel=\"bookmark\" class=\"comment_permalink\">#{$hash}</a> <a href=\"" . htmlentities($url) . "\" rel=\"external nofollow\" class=\"url fn\">{$name}</a></span>"; } else { $namepr = "<span class=\"message_name author\"><a href=\"{$permalink}#comment_{$hash}\" rel=\"bookmark\" class=\"comment_permalink\">#{$hash}</a> <span class=\"fn\">{$name}</span></span>"; } if (is_even($i + 1)) { $type = 'comment_even'; } else { $type = 'comment_odd'; } if ($admin_user == 'yes') { $atype = ' comment_admin'; } else { $atype = ""; } $logunix = returnUnixtimestamp($posted); $days_ago = safe_strftime('since', $logunix); $microformatcomment = safe_strftime('%Y-%m-%dT%T%z', $logunix); $commenttimeclass = safe_strftime('c_y%Y c_m%m c_d%d c_h%H', $logunix); echo "\n\t\t\t\t\t\t<div class=\"{$type} hentry comment comment_author_" . str_replace('-', '_', make_slug($name)) . " {$commenttimeclass}" . $atype . "\" id=\"comment_{$hash}\">\n\t\t\t\t\t\t\t<div class=\"comment_message\">\n\t\t\t\t\t\t\t\t<div class=\"message_details vcard\">\n\t\t\t\t\t\t\t\t\t<img src=\"{$grav_url}\" alt=\"Gravatar Image\" class=\"gr photo\" />\n\t\t\t\t\t\t\t\t\t{$namepr}\n\t\t\t\t\t\t\t\t\t<span class=\"message_time\"><abbr class=\"published\" title=\"{$microformatcomment}\">{$days_ago}</abbr></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"message_body entry-title entry-content\"><p>{$comment}</p></div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>"; $i++; } } else { echo "\n\t\t\t\t\t\t<span class=\"comments_none\">" . $lang['no_comments'] . "</span>"; } echo "\n\t\t\t\t\t</div>\n"; echo "\n\t\t\t\t\t<div class=\"comment_form\" id=\"commentform\">"; if ($comment_ok) { echo "\n\t\t\t\t\t\t\t<p class=\"success\">" . $lang['comment_thanks'] . '</p>'; } else { if ($comments == 'yes') { if (isset($s)) { $posty = createURL($s, $m, $x); } echo "\n\t\t\t\t\t\t<form accept-charset=\"UTF-8\" action=\"{$posty}#commentform\" method=\"post\" class=\"form\">\n\t\t\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\t\t var blogTool = \"pixie\";\n\t\t\t\t\t\t var blogURL = \"{$site_url}\";\n\t\t\t\t\t\t var blogTitle = \"{$site_name} - {$page_display_name}\";\n\t\t\t\t\t\t var postURL = \"{$posty}\";\n\t\t\t\t\t\t var postTitle = \"{$title}\";\n\t\t\t\t\t\t var commentTextFieldName = \"comment\";\n\t\t\t\t\t\t var commentButtonName = \"comment_submit\";"; if (isset($realname) && $realname) { echo "\n\t\t\t\t\t\t var commentAuthorLoggedIn = true;"; } else { echo "\n\t\t\t\t\t\t var commentAuthorLoggedIn = false;"; } echo "\n\t\t\t\t\t\t var commentAuthorFieldName = \"name\";\n\t\t\t\t\t\t var commentFormID = \"commentform\";\n\t\t\t\t\t\t</script>\n\t\t\t\t\t\t\t<fieldset>\n\t\t\t\t\t\t\t\t<legend>" . $lang['comment_leave'] . "</legend>"; if (isset($error)) { echo "\n\t\t\t\t\t\t\t\t<p class=\"error\">{$error}</p>"; if (in_array('name', $scream)) { $name_style = 'form_highlight'; } if (in_array('comment', $scream)) { $comment_style = 'form_highlight'; } if (in_array('email', $scream)) { $email_style = 'form_highlight'; } if (in_array('web', $scream)) { $web_style = 'form_highlight'; } } else { echo "<p class=\"notice\">" . $lang['comment_form_info'] . "</p>"; } echo "\n\t\t\t\t\t\t\t\t<div class=\"form_row "; if (isset($name_style)) { echo $name_style; } echo "\">\n\t\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"comment_name\">" . $lang['comment_name'] . " <span class=\"form_required\">" . $lang['form_required'] . "</span></label></div>"; if (isset($realname) && $realname) { echo "\n\t\t\t\t\t\t\t\t\t<div class=\"form_item\"><input type=\"text\" disabled=\"disabled\" tabindex=\"1\" name=\"name\" class=\"form_text\" id=\"comment_name\""; if (isset($realname)) { echo " value=\"{$realname}\""; } echo " /></div>"; } else { echo "\n\t\t\t\t\t\t\t\t<div class=\"form_item\"><input type=\"text\" tabindex=\"1\" name=\"name\" class=\"form_text\" id=\"comment_name\" value=\"{$sname}\"/></div>"; } if ($sweb == "") { $sweb = 'http://'; } if (isset($realname) && $realname) { $sweb = $site_url; $semail = $umail; } echo "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"form_row "; if (isset($email_style)) { echo $email_style; } echo "\">\n\t\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"comment_email\">" . $lang['comment_email'] . " <span class=\"form_required\">" . $lang['form_required'] . "</span></label></div>\n\t\t\t\t\t\t\t\t\t<div class=\"form_item\"><input type=\"text\" tabindex=\"2\" name=\"email\" class=\"form_text\" id=\"comment_email\" value=\"{$semail}\" /></div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"form_row "; if (isset($web_style)) { echo $web_style; } echo "\">\n\t\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"comment_web\">" . $lang['comment_web'] . " <span class=\"form_optional\">" . $lang['form_optional'] . "</span></label></div>\n\t\t\t\t\t\t\t\t\t<div class=\"form_item\"><input type=\"text\" tabindex=\"2\" name=\"web\" class=\"form_text\" id=\"comment_web\" value=\"{$sweb}\" /></div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"form_row "; if (isset($comment_style)) { echo $comment_style; } echo "\">\n\t\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"comment\">" . $lang['comment'] . " <span class=\"form_required\">" . $lang['form_required'] . "</span></label></div>\n\t\t\t\t\t\t\t\t\t<div class=\"form_item\"><textarea name=\"comment\" tabindex=\"3\" id=\"comment\" class=\"form_text_area\" cols=\"25\" rows=\"5\">{$scomment}</textarea></div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"form_row_submit\">\n\t\t\t\t\t\t\t\t\t<input type=\"submit\" name=\"comment_submit\" tabindex=\"4\" value=\"" . $lang['comment_button_leave'] . "\" class=\"form_submit\" />\n\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"post\" value=\"{$post_id}\" />"; if (isset($realname) && $realname) { echo "\n\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"admin_user\" value=\"" . md5($nonce) . "\" />\n\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"name\""; if (isset($realname)) { echo " value=\"{$realname}\""; } echo " />"; } echo "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</fieldset>\n\t\t\t\t\t\t</form>"; } else { echo "\n\t\t\t\t\t\t<span class=\"comments_closed\">" . $lang['comment_closed'] . "</span>"; } } echo "\n\t\t\t\t\t</div>"; } // end if comments plugin enabled } } else { extract(safe_row('*', 'pixie_core', "page_name='404'")); extract(safe_row('*', 'pixie_static_posts', "page_id='{$page_id}'")); if (isset($s)) { echo "<div id=\"{$s}\">\n\t\t\t\t\t\t<h3>{$page_display_name}</h3>\n"; eval('?>' . $page_content . '<?php '); echo "\n\t\t\t\t\t</div>\n"; } } }
} if ('before' == raindrops_warehouse('raindrops_posted_in_position')) { raindrops_posted_in(); } ?> </div> <div class="entry-content clearfix"> <?php raindrops_prepend_entry_content(); $content = $post->post_content; $content = apply_filters('the_content', $content); $content = apply_filters('raindrops_entry_content', $content); $content = str_replace(']]>', ']]>', $content); $content = str_replace('<span id="more-' . $post->ID . '"></span>', '<!--more-->', $content); $text_array = get_extended($content); if (empty($text_array['more_text'])) { $text_array['more_text'] = esc_html__('Continue reading ', 'raindrops') . '<span class="meta-nav">→</span><span class="more-link-post-unique">' . esc_html__(' Post ID ', 'raindrops') . get_the_ID() . '</span>'; } if ($text_array['extended'] !== '') { $text_array['main'] .= sprintf('<p class="additional-more"><a href="%1$s"><span>%2$s</span></a></p>', get_permalink(), $text_array['more_text']); } if (has_post_thumbnail($post->ID) && is_front_page()) { ?> <div class="line"> <div class="unit size1of4"><?php the_post_thumbnail(); ?> </div> <div class="unit size3of4"><?php echo $text_array['main'];
function mt_getpost($params) { // ($postid, $user, $pass) global $xmlrpcerruser; $xpostid = $params->getParam(0); $xuser = $params->getParam(1); $xpass = $params->getParam(2); $post_ID = $xpostid->scalarval(); $username = $xuser->scalarval(); $password = $xpass->scalarval(); // Check login if (user_pass_ok($username, $password)) { $postdata = get_postdata($post_ID); if ($postdata["Date"] != "") { // why were we converting to GMT here? spec doesn't call for that. //$post_date = mysql2date("U", $postdata["Date"]); //$post_date = gmdate("Ymd", $post_date)."T".gmdate("H:i:s", $post_date); $post_date = strtotime($postdata['Date']); $post_date = date("Ymd", $post_date) . "T" . date("H:i:s", $post_date); $catids = wp_get_post_cats('1', $post_ID); logIO("O", "CateGory No:" . count($catids)); foreach ($catids as $catid) { $catname = get_cat_name($catid); logIO("O", "CateGory:" . $catname); $catnameenc = new xmlrpcval(mb_conv($catname, "UTF-8", "auto")); $catlist[] = $catnameenc; } $post = get_extended($postdata['Content']); $allow_comments = 'open' == $postdata['comment_status'] ? 1 : 0; $allow_pings = 'open' == $postdata['ping_status'] ? 1 : 0; $resp = array('link' => new xmlrpcval(post_permalink($post_ID)), 'title' => new xmlrpcval(mb_conv($postdata["Title"], "UTF-8", "auto")), 'description' => new xmlrpcval(mb_conv($post['main'], "UTF-8", "auto")), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'userid' => new xmlrpcval($postdata["Author_ID"]), 'postid' => new xmlrpcval($postdata["ID"]), 'content' => new xmlrpcval(mb_conv($postdata["Content"], "UTF-8", "auto")), 'permalink' => new xmlrpcval(post_permalink($post_ID)), 'categories' => new xmlrpcval($catlist, 'array'), 'mt_keywords' => new xmlrpcval("{$catids[0]}"), 'mt_excerpt' => new xmlrpcval(mb_conv($postdata['Excerpt'], "UTF-8", "auto")), 'mt_allow_comments' => new xmlrpcval($allow_comments, 'int'), 'mt_allow_pings' => new xmlrpcval($allow_pings, 'int'), 'mt_convert_breaks' => new xmlrpcval('true'), 'mt_text_more' => new xmlrpcval(mb_conv($post['extended'], "UTF-8", "auto"))); $resp = new xmlrpcval($resp, 'struct'); return new xmlrpcresp($resp); } else { return new xmlrpcresp(0, $xmlrpcerruser + 3, "No such post #{$post_ID}"); } } else { return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password)); } }
<?php $config = array('name' => 'content/woocommerce', 'main' => 'YOOtheme\\Widgetkit\\Content\\Type', 'config' => function ($app) { return array('name' => 'woocommerce', 'label' => 'WooCommerce', 'icon' => $app['url']->to('plugins/content/woocommerce/content.svg'), 'item' => array('title', 'content', 'media', 'link'), 'data' => array('number' => 5, 'content' => 'intro', 'category' => '', 'order_by' => 'post_date')); }, 'items' => function ($items, $content) { $order = explode('_asc', $content['order_by']); $args = array('numberposts' => $content['number'] ?: 5, 'orderby' => isset($order[0]) ? $order[0] : 'post_date', 'order' => isset($order[1]) ? 'ASC' : 'DESC', 'post_status' => 'publish', 'post_type' => 'product'); if ($content['category'] > 0) { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => (int) $content['category'], 'include_children' => false)); } foreach (get_posts($args) as $post) { $data = array(); $data['title'] = get_the_title($post->ID); $data['link'] = get_permalink($post->ID); $pieces = get_extended($post->post_content); if ($content['content'] == 'excerpt') { $data['content'] = apply_filters('the_content', $post->post_excerpt); } else { if ($content['content'] == 'intro') { $data['content'] = apply_filters('the_content', $pieces['main']); } else { $data['content'] = apply_filters('the_content', $pieces['main'] . $pieces['extended']); } } // media: TODO if ($thumbnail = get_post_thumbnail_id($post->ID)) { $image = wp_get_attachment_image_src($thumbnail, 'full'); $data['media'] = $image[0]; } $items->add($data); }
/** * Get extended entry info (<!--more-->). * * There should not be any space after the second dash and before the word * 'more'. There can be text or space(s) after the word 'more', but won't be * referenced. * * The returned array has 'main', 'extended', and 'more_text' keys. Main has the text before * the `<!--more-->`. The 'extended' key has the content after the * `<!--more-->` comment. The 'more_text' key has the custom "Read More" text. * * @since 1.0.0 * * @param string $post Post content. * @return array Post before ('main'), after ('extended'), and custom readmore ('more_text'). */ public function getExtended($post) { return get_extended($post); }
?> '"><?php the_title(); ?> </div> <a href="<?php the_permalink(); ?> " class="img_m_a"><?php echo get_the_post_thumbnail($post->ID); ?> </a> <div class="text_m_a"> <?php echo get_extended($post->post_content)['main']; ?> </div> <div class="read_more_m_a" onclick="location.href='<?php the_permalink(); ?> '">Читать подробнее</div> <div class="share_m_a"> <span class="share_m_a_name">Рассказать друзьям:</span> <div class="vk_m_a"> <div class="s_icon"></div> <div class="s_number">24</div> </div> <div class="fb_m_a"> <div class="s_icon"></div>
/** * Возвращает результат поиска * @param string $searchString * @return array */ function getSearchResults($searchString) { global $post, $wp_query; $result = array(); // Навигация $pagesHtml = paginate_links(array('base' => '%_%', 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages, 'end_size' => 4, 'mid_size' => 4, 'prev_text' => '<', 'next_text' => '>', 'type' => 'array')); $result['paginate'] = $pagesHtml; $result['posts'] = array(); if (have_posts()) { while (have_posts()) { the_post(); $post->fields = get_fields($post->ID); $post->permalink = get_permalink($post->ID); // Получаем текст поста $content = get_post_field('post_content', $post->ID); $post->contentParts = get_extended($content); // Метки $post->terms = wp_get_post_tags($post->ID); $result['posts'][] = $post; } } return $result; }
/** * * get intro from content */ public static function getIntroFromContent($text) { $intro = ""; if (!empty($text)) { $arrExtended = get_extended($text); $intro = UniteFunctionsBiz::getVal($arrExtended, "main"); /* if(strlen($text) != strlen($intro)) $intro .= "..."; */ } return $intro; }
function express_getPostsWithOffset($args) { global $wpdb; global $wp_xmlrpc_server; $wp_xmlrpc_server->escape($args); $blog_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $num_posts = (int) $args[3]; $offset = (int) $args[4]; $status = $args[5]; if (!($user = $wp_xmlrpc_server->login($username, $password))) { return $wp_xmlrpc_server->error; } do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); // -- Added code if ($status == '') { $statuses = "'draft', 'publish', 'future', 'pending', 'private'"; } else { $status_array = explode(",", $status); $statuses = "'" . implode("','", $status_array) . "'"; } $sql = "SELECT * FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status IN ( {$statuses} ) ORDER BY post_date DESC LIMIT {$offset},{$num_posts}"; $result = $wpdb->get_results($sql, ARRAY_A); $posts_list = $result ? $result : array(); // End added code -- if (!$posts_list) { return array(); } foreach ($posts_list as $entry) { if (!current_user_can('edit_post', $entry['ID'])) { continue; } $post_date = mysql2date('Ymd\\TH:i:s', $entry['post_date'], false); $post_date_gmt = mysql2date('Ymd\\TH:i:s', $entry['post_date_gmt'], false); // For drafts use the GMT version of the date if ($entry['post_status'] == 'draft') { $post_date_gmt = get_gmt_from_date(mysql2date('Y-m-d H:i:s', $entry['post_date']), 'Ymd\\TH:i:s'); } $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach ($catids as $catid) { $categories[] = get_cat_name($catid); } $tagnames = array(); $tags = wp_get_post_tags($entry['ID']); if (!empty($tags)) { foreach ($tags as $tag) { $tagnames[] = $tag->name; } $tagnames = implode(', ', $tagnames); } else { $tagnames = ''; } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); // Get the post author info. $author = get_userdata($entry['post_author']); $allow_comments = 'open' == $entry['comment_status'] ? 1 : 0; $allow_pings = 'open' == $entry['ping_status'] ? 1 : 0; // Consider future posts as published if ($entry['post_status'] === 'future') { $entry['post_status'] = 'publish'; } $struct[] = array('dateCreated' => new IXR_Date($post_date), 'userid' => $entry['post_author'], 'postid' => $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], 'wp_author_id' => $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => new IXR_Date($post_date_gmt), 'post_status' => $entry['post_status'], 'custom_fields' => $wp_xmlrpc_server->get_custom_fields($entry['ID'])); } $recent_posts = array(); for ($j = 0; $j < count($struct); $j++) { array_push($recent_posts, $struct[$j]); } return $recent_posts; }
/** * Retrieve list of recent posts. * * @since 1.5.0 * * @param array $args Method parameters. * @return array */ function mw_getRecentPosts($args) { $this->escape($args); $blog_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; if (isset($args[3])) { $query = array('numberposts' => absint($args[3])); } else { $query = array(); } if (!($user = $this->login($username, $password))) { return $this->error; } do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); $posts_list = wp_get_recent_posts($query); if (!$posts_list) { return array(); } $struct = array(); foreach ($posts_list as $entry) { if (!current_user_can('edit_post', $entry['ID'])) { continue; } $post_date = $this->_convert_date($entry['post_date']); $post_date_gmt = $this->_convert_date_gmt($entry['post_date_gmt'], $entry['post_date']); $post_modified = $this->_convert_date($entry['post_modified']); $post_modified_gmt = $this->_convert_date_gmt($entry['post_modified_gmt'], $entry['post_modified']); $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach ($catids as $catid) { $categories[] = get_cat_name($catid); } $tagnames = array(); $tags = wp_get_post_tags($entry['ID']); if (!empty($tags)) { foreach ($tags as $tag) { $tagnames[] = $tag->name; } $tagnames = implode(', ', $tagnames); } else { $tagnames = ''; } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); // Get the post author info. $author = get_userdata($entry['post_author']); $allow_comments = 'open' == $entry['comment_status'] ? 1 : 0; $allow_pings = 'open' == $entry['ping_status'] ? 1 : 0; // Consider future posts as published if ($entry['post_status'] === 'future') { $entry['post_status'] = 'publish'; } // Get post format $post_format = get_post_format($entry['ID']); if (empty($post_format)) { $post_format = 'standard'; } $struct[] = array('dateCreated' => $post_date, 'userid' => $entry['post_author'], 'postid' => (string) $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'wp_more_text' => $post['more_text'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], 'wp_author_id' => (string) $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => $post_date_gmt, 'post_status' => $entry['post_status'], 'custom_fields' => $this->get_custom_fields($entry['ID']), 'wp_post_format' => $post_format, 'date_modified' => $post_modified, 'date_modified_gmt' => $post_modified_gmt); $entry_index = count($struct) - 1; $struct[$entry_index]['wp_post_thumbnail'] = get_post_thumbnail_id($entry['ID']); } $recent_posts = array(); for ($j = 0; $j < count($struct); $j++) { array_push($recent_posts, $struct[$j]); } return $recent_posts; }
echo '</div>'; echo '<img src="http://www.shfamilylaw.ca/wp-content/themes/sheri/images/background/blog_dotted_line_bg.png">'; } else { $page_id = $array_ids[$i]; // Enter your post, page or custom post type id here $page_data = get_page($page_id); //gets all page data //print_r($page_data); $content = $page_data->post_content; //filters just the post content $title = $page_data->post_title; // Get title $src_featured = wp_get_attachment_image_src(get_post_thumbnail_id($array_ids[$i]), 'full', false, ''); $image_data = wp_get_attachment_image_src(get_post_thumbnail_id($array_ids[$i]), "full"); $image_height = $image_data[2]; $trimmedfield = get_extended($content); $date = date_create($page_data->post_date); $new_date = date_format($date, "l jS \\of F Y"); $user_firstname = get_the_author_meta('first_name', $page_data->post_author); $user_lastname = get_the_author_meta('last_name', $page_data->post_author); echo '<div class="blog_post" style="height:' . $image_height . 'px;">'; echo '<img class="blog_left_align_image" src="' . $src_featured[0] . ' ">'; // echo 'left'; echo '<a href="' . $pages[$x]->ID . '"><h1>' . $title . '</h1></a>'; echo '<span class="blog_post_date">' . $new_date . ' | ' . $user_firstname . ' ' . $user_lastname . '</span>'; echo "<p>" . $trimmedfield['main'] . "</p>"; echo "<a class='read_more_button' href='" . $page_data->guid . "'>READ MORE</a>"; echo '</div>'; echo '<img src="http://www.shfamilylaw.ca/wp-content/themes/sheri/images/background/blog_dotted_line_bg.png">'; } }
/** * Retrieve list of recent posts. * * @since 1.5.0 * * @param array $args Method parameters. * @return array|IXR_Error */ public function mw_getRecentPosts($args) { $this->escape($args); $username = $args[1]; $password = $args[2]; if (isset($args[3])) { $query = array('numberposts' => absint($args[3])); } else { $query = array(); } if (!($user = $this->login($username, $password))) { return $this->error; } if (!current_user_can('edit_posts')) { return new IXR_Error(401, __('Sorry, you cannot edit posts on this site.')); } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); $posts_list = wp_get_recent_posts($query); if (!$posts_list) { return array(); } $recent_posts = array(); foreach ($posts_list as $entry) { if (!current_user_can('edit_post', $entry['ID'])) { continue; } $post_date = $this->_convert_date($entry['post_date']); $post_date_gmt = $this->_convert_date_gmt($entry['post_date_gmt'], $entry['post_date']); $post_modified = $this->_convert_date($entry['post_modified']); $post_modified_gmt = $this->_convert_date_gmt($entry['post_modified_gmt'], $entry['post_modified']); $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach ($catids as $catid) { $categories[] = get_cat_name($catid); } $tagnames = array(); $tags = wp_get_post_tags($entry['ID']); if (!empty($tags)) { foreach ($tags as $tag) { $tagnames[] = $tag->name; } $tagnames = implode(', ', $tagnames); } else { $tagnames = ''; } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); // Get the post author info. $author = get_userdata($entry['post_author']); $allow_comments = 'open' == $entry['comment_status'] ? 1 : 0; $allow_pings = 'open' == $entry['ping_status'] ? 1 : 0; // Consider future posts as published if ($entry['post_status'] === 'future') { $entry['post_status'] = 'publish'; } // Get post format $post_format = get_post_format($entry['ID']); if (empty($post_format)) { $post_format = 'standard'; } $recent_posts[] = array('dateCreated' => $post_date, 'userid' => $entry['post_author'], 'postid' => (string) $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'wp_more_text' => $post['more_text'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], 'wp_author_id' => (string) $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => $post_date_gmt, 'post_status' => $entry['post_status'], 'custom_fields' => $this->get_custom_fields($entry['ID']), 'wp_post_format' => $post_format, 'date_modified' => $post_modified, 'date_modified_gmt' => $post_modified_gmt, 'sticky' => $entry['post_type'] === 'post' && is_sticky($entry['ID']), 'wp_post_thumbnail' => get_post_thumbnail_id($entry['ID'])); } return $recent_posts; }
<?php if ($fields->show_date) { ?> <p><time><?php echo get_the_time('Y-m-d H:i', $post->ID); ?> </time></p> <?php } ?> <?php if ($fields->show_excerpt) { ?> <p><?php echo isset(get_extended($post->post_content)['main']) ? apply_filters('the_excerpt', wp_trim_words(wp_strip_all_tags(strip_shortcodes(get_extended($post->post_content)['main'])), 30, null)) : ''; ?> </p> <?php } ?> </div> </a> </div> <?php } } else { ?> <div class="grid-md-12"> Inga inlägg att visa… </div>
/** * Manage custom column for Post Types. * * @since 1.0 */ public function manage_posts_column_value($column_name, $post_id) { $type = $column_name; // Check for taxonomies, such as column-taxonomy-[taxname] if (strpos($type, 'column-taxonomy-') !== false) { $type = 'column-taxonomy'; } // Check for custom fields, such as column-meta-[customfieldname] if ($this->is_column_meta($type)) { $type = 'column-post-meta'; } // Hook do_action('cpac-manage-posts-column', $type, $column_name, $post_id); // Switch Types $result = ''; switch ($type) { // Post ID case "column-postid": $result = $post_id; break; // Excerpt // Excerpt case "column-excerpt": $result = $this->get_post_excerpt($post_id); break; // Featured Image // Featured Image case "column-featured_image": if (function_exists('has_post_thumbnail') && has_post_thumbnail($post_id)) { $result = get_the_post_thumbnail($post_id, $this->thumbnail_size); } break; // Sticky Post // Sticky Post case "column-sticky": if (is_sticky($post_id)) { $result = $this->get_asset_image('checkmark.png'); } break; // Order // Order case "column-order": $result = get_post_field('menu_order', $post_id); break; // Post Formats // Post Formats case "column-post_formats": $result = get_post_format($post_id); break; // Page template // Page template case "column-page-template": // file name $page_template = get_post_meta($post_id, '_wp_page_template', true); // get template nice name $result = array_search($page_template, get_page_templates()); break; // Slug // Slug case "column-page-slug": $result = get_post($post_id)->post_name; break; // Slug // Slug case "column-word-count": $result = str_word_count($this->strip_trim(get_post($post_id)->post_content)); break; // Taxonomy // Taxonomy case "column-taxonomy": $tax = str_replace('column-taxonomy-', '', $column_name); $tags = get_the_terms($post_id, $tax); $tarr = array(); // for post formats we will display standard instead of empty if ($tax == 'post_format' && empty($tags)) { $result = __('Standard'); } elseif (!empty($tags)) { $post_type = get_post_type($post_id); foreach ($tags as $tag) { // sanatize title if (isset($tag->term_id)) { $tax_title = esc_html(sanitize_term_field('name', $tag->name, $tag->term_id, $tag->taxonomy, 'edit')); $tarr[] = "<a href='edit.php?post_type={$post_type}&{$tag->taxonomy}={$tag->slug}'>{$tax_title}</a>"; } } $result = implode(', ', $tarr); } break; // Custom Field // Custom Field case "column-post-meta": $result = $this->get_column_value_custom_field($post_id, $column_name, 'post'); break; // Attachment // Attachment case "column-attachment": $result = $this->get_column_value_attachments($post_id); break; // Attachment count // Attachment count case "column-attachment-count": $result = count($this->get_attachment_ids($post_id)); break; // Roles // Roles case "column-roles": $user_id = get_post($post_id)->post_author; $userdata = get_userdata($user_id); if (!empty($userdata->roles[0])) { $result = implode(', ', $userdata->roles); } break; // Post status // Post status case "column-status": $p = get_post($post_id); $result = $this->get_post_status_friendly_name($p->post_status); if ($p->post_status == 'future') { $result = $result . " <p class='description'>" . date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($p->post_date)) . "</p>"; } break; // Post comment status // Post comment status case "column-comment-status": $p = get_post($post_id); $result = $this->get_asset_image('no.png', $p->comment_status); if ($p->comment_status == 'open') { $result = $this->get_asset_image('checkmark.png', $p->comment_status); } break; // Post ping status // Post ping status case "column-ping-status": $p = get_post($post_id); $result = $this->get_asset_image('no.png', $p->ping_status); if ($p->ping_status == 'open') { $result = $this->get_asset_image('checkmark.png', $p->ping_status); } break; // Post actions ( delete, edit etc. ) // Post actions ( delete, edit etc. ) case "column-actions": $result = $this->get_column_value_actions($post_id); break; // Post Last modified // Post Last modified case "column-modified": $p = get_post($post_id); $result = $this->get_date($p->post_modified) . ' ' . $this->get_time($p->post_modified); break; // Post Comment count // Post Comment count case "column-comment-count": $result = WP_List_Table::comments_bubble($post_id, get_pending_comments_num($post_id)); $result .= $this->get_comment_count_details($post_id); break; // Author Name // Author Name case "column-author-name": $result = $this->get_column_value_authorname($post_id, $column_name); break; // Before More Tag // Before More Tag case "column-before-moretag": $p = get_post($post_id); $extended = get_extended($p->post_content); if (!empty($extended['extended'])) { $result = $this->get_shortened_string($extended['main'], $this->excerpt_length); } break; default: $result = ''; } // Filter for customizing the result output apply_filters('cpac-posts-column-result', $result, $type, $column_name, $post_id); echo $result; }
/** * Retrieve list of recent posts. * * @since 1.5.0 * * @param array $args Method parameters. * @return array */ function mw_getRecentPosts($args) { $this->escape($args); $blog_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $num_posts = (int) $args[3]; if (!($user = $this->login($username, $password))) { return $this->error; } do_action('xmlrpc_call', 'metaWeblog.getRecentPosts'); $posts_list = wp_get_recent_posts($num_posts); if (!$posts_list) { return array(); } foreach ($posts_list as $entry) { if (!current_user_can('edit_post', $entry['ID'])) { continue; } $post_date = mysql2date('Ymd\\TH:i:s', $entry['post_date'], false); $post_date_gmt = mysql2date('Ymd\\TH:i:s', $entry['post_date_gmt'], false); // For drafts use the GMT version of the date if ($entry['post_status'] == 'draft') { $post_date_gmt = get_gmt_from_date(mysql2date('Y-m-d H:i:s', $entry['post_date']), 'Ymd\\TH:i:s'); } $categories = array(); $catids = wp_get_post_categories($entry['ID']); foreach ($catids as $catid) { $categories[] = get_cat_name($catid); } $tagnames = array(); $tags = wp_get_post_tags($entry['ID']); if (!empty($tags)) { foreach ($tags as $tag) { $tagnames[] = $tag->name; } $tagnames = implode(', ', $tagnames); } else { $tagnames = ''; } $post = get_extended($entry['post_content']); $link = post_permalink($entry['ID']); // Get the post author info. $author = get_userdata($entry['post_author']); $allow_comments = 'open' == $entry['comment_status'] ? 1 : 0; $allow_pings = 'open' == $entry['ping_status'] ? 1 : 0; // Consider future posts as published if ($entry['post_status'] === 'future') { $entry['post_status'] = 'publish'; } $struct[] = array('dateCreated' => new IXR_Date($post_date), 'userid' => $entry['post_author'], 'postid' => $entry['ID'], 'description' => $post['main'], 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], 'mt_text_more' => $post['extended'], 'mt_allow_comments' => $allow_comments, 'mt_allow_pings' => $allow_pings, 'mt_keywords' => $tagnames, 'wp_slug' => $entry['post_name'], 'wp_password' => $entry['post_password'], 'wp_author_id' => $author->ID, 'wp_author_display_name' => $author->display_name, 'date_created_gmt' => new IXR_Date($post_date_gmt), 'post_status' => $entry['post_status'], 'custom_fields' => $this->get_custom_fields($entry['ID'])); } $recent_posts = array(); for ($j = 0; $j < count($struct); $j++) { array_push($recent_posts, $struct[$j]); } return $recent_posts; }