source: trunk/www.guidonia.net/wp/wp-content/themes/carrington-mobile-1.0.2/carrington-core/ajax-load.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 2.7 KB
Line 
1<?php
2
3// This file is part of the Carrington Theme Framework for WordPress
4// http://carringtontheme.com
5//
6// Copyright (c) 2008-2009 Crowd Favorite, Ltd. All rights reserved.
7// http://crowdfavorite.com
8//
9// Released under the GPL license
10// http://www.opensource.org/licenses/gpl-license.php
11//
12// **********************************************************************
13// This program is distributed in the hope that it will be useful, but
14// WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16// **********************************************************************
17
18if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
19
20function cfct_ajax_post_content($post_id) {
21 global $post, $posts, $wp_query, $wp;
22 $posts = get_posts('include='.$post_id);
23 $post = $posts[0];
24 if (is_null($post)) {
25 $posts = get_pages('include='.$post_id);
26 $post = $posts[0];
27 }
28 if (is_null($post)) {
29 $posts = get_posts('post_status=private&include='.$post_id);
30 $post = $posts[0];
31 if ($post) {
32 $user = wp_get_current_user();
33 if (!$user->ID || $user->ID != $post->post_author) {
34 $post = null;
35 }
36 }
37 }
38 if (!$post) {
39 die('');
40 }
41 $wp_query->in_the_loop = true;
42 setup_postdata($post);
43 remove_filter('the_content', 'st_add_widget');
44 $wp->send_headers();
45 cfct_content();
46 echo '<div class="close" id="post_close_'.$post_id.'"><a href="#">'.__('Close', 'carrington').'</a></div>';
47}
48
49function cfct_ajax_post_comments($post_id) {
50 global $post, $posts, $wp_query, $wp;
51 $wp_query->is_single = true;
52 $posts = get_posts('include='.$post_id);
53 $post = $posts[0];
54 if (is_null($post)) {
55 $posts = get_pages('include='.$post_id);
56 $post = $posts[0];
57 }
58 setup_postdata($post);
59 $wp->send_headers();
60 comments_template();
61}
62
63function cfct_ajax_load() {
64 if (isset($_GET['cfct_action'])) {
65 switch ($_GET['cfct_action']) {
66 case 'post_content':
67 case 'post_comments':
68 if (isset($_GET['id'])) {
69 $post_id = intval($_GET['id']);
70 }
71 else if (isset($_GET['url'])) {
72 $post_id = url_to_post_id($_GET['url']);
73 }
74 if ($post_id) {
75 call_user_func('cfct_ajax_'.$_GET['cfct_action'], $post_id);
76 die();
77 }
78 }
79 }
80}
81
82function cfct_ajax_comment_link() {
83 global $post;
84 echo ' rev="post-'.$post->ID.'" ';
85}
86add_filter('comments_popup_link_attributes', 'cfct_ajax_comment_link');
87
88function cfct_posts_per_archive_page($query) {
89 $count = get_option('cfct_posts_per_archive_page');
90 intval($count) > 0 ? $count = $count : $count = 25;
91 $query->set('posts_per_archive_page', $count);
92 if (is_category()) {
93 $query->set('posts_per_page', $count);
94 }
95 return $query;
96}
97add_filter('pre_get_posts', 'cfct_posts_per_archive_page');
98
99?>
Note: See TracBrowser for help on using the repository browser.