Changeset 734086
- Timestamp:
- 06/29/2013 06:08:20 PM (13 years ago)
- Location:
- article-forge/trunk
- Files:
-
- 2 added
- 11 edited
-
ArticleForge.php (modified) (4 diffs)
-
ArticleForge/Admin.php (modified) (2 diffs)
-
ArticleForge/Admin/Hacks.php (modified) (1 diff)
-
ArticleForge/Constants.php (modified) (1 diff)
-
ArticleForge/Content.php (modified) (1 diff)
-
ArticleForge/Content/ActionMap.php (modified) (2 diffs)
-
content/default/article-section.php (modified) (1 diff)
-
content/default/js (added)
-
content/default/js/articleforge.js (added)
-
content/default/single-summary.php (modified) (6 diffs)
-
functions.php (modified) (1 diff)
-
main.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
article-forge/trunk/ArticleForge.php
r729145 r734086 174 174 $cquery->next_post(); 175 175 if ($cquery->post->post_status == 'draft') { 176 if (is_user_logged_in() && ($cquery->post->post_author == get_current_user_id()) 176 if (is_user_logged_in() && 177 current_user_can('read', $cquery->post->ID) 177 178 && (array_key_exists('preview', $_GET) && ($_GET['preview'] == 'true'))) { 178 179 $section = $cquery->post; … … 187 188 if (isset($article)) { 188 189 $url = site_url('/' . $this->options->single_slug . '/' . $article->post_name . '/' . $this->options->section_slug . '/' . $section->post_name); 189 if (array_key_exists('preview', $_GET)) 190 $url = add_query_arg(array( 'preview' => $_GET['preview']), $url); 190 foreach ($_GET as $key => $value) { 191 if (!in_array($key, array('p', 'post_type', 'name'))) { 192 $url = add_query_arg(array($key => $value), $url); 193 } 194 } 191 195 wp_safe_redirect($url); 192 196 exit(); … … 214 218 if (isset($post_post)) { 215 219 $statuses = array('publish'); 216 if (is_user_logged_in() && ($post_post->post_author == get_current_user_id())217 && (array_key_exists('preview', $_GET) && ($_GET['preview'] == 'true'))) array_push($statuses, 'draft');220 if (is_user_logged_in() && current_user_can('read', $post_post->ID) 221 && array_key_exists('preview', $_GET) && ($_GET['preview'] == 'true')) array_push($statuses, 'draft'); 218 222 // use author id and _GET to determine if we should allow draft to $statuses 219 223 // get section from post id and section name … … 238 242 } 239 243 return !$wp_query->is_404(); 240 }241 242 public function home($wp_query) {243 if ( $this->options->show_on_home == 'true' ) {244 $wp_query->set('post_type', af_namespace() . '_' . ArticleForge\Constants::SummaryPostType);245 //$wp_query->is_post_type_archive = true;246 //$wp_query->is_archive = true;247 }248 244 } 249 245 -
article-forge/trunk/ArticleForge/Admin.php
r728624 r734086 203 203 $post_parent = $post->post_parent == 0 ? (array_key_exists('post_parent', $_GET) ? $_GET['post_parent'] : 0 ) : $post->post_parent; 204 204 $article = get_post($post_parent); 205 if (!$article || ($article->post_type != af_namespace() . '_' . Constants::SummaryPostType) ||206 !in_array($article->post_status, array('draft', 'publish')) || ($article->post_author != get_current_user_id())) {207 wp_die('The parent article is not available for new sections.');208 }209 205 ?> 210 206 <input type="hidden" id="parent_id" name="parent_id" value="<?php echo $post_parent; ?>"/> … … 358 354 if (!array_key_exists('post_parent', $_GET)) { 359 355 wp_die('Create new content sections from the article edit page please.'); 356 } 357 $post_parent = $_GET['post_parent']; 358 $article = get_post($post_parent); 359 if (!$article || ($article->post_type != af_namespace() . '_' . Constants::SummaryPostType) || 360 !in_array($article->post_status, array('draft', 'publish')) || 361 (!current_user_can('edit_post', $post_parent)) 362 ) { 363 wp_die('The parent article is not available for new sections.'); 360 364 } 361 365 } -
article-forge/trunk/ArticleForge/Admin/Hacks.php
r728458 r734086 37 37 38 38 public static function insert_post($post_id) { 39 // ArticleForge has checks in place to prevent unauthorized viewing of draftarticles.39 // ArticleForge doesn't populate post_name for draft articles which prevents unauthorized viewing of these articles. 40 40 // Populate post_name to allow previewing of draft articles. 41 41 global $wpdb; 42 42 $post_type = get_post_type( $post_id ); 43 43 if (!is_post_type_namespace(af_namespace(), $post_type)) return; 44 if (strcmp($post_type, af_namespace() . '_' . \ArticleForge\Constants::ContentPostType) == 0) { 45 $section = get_post($post_id); 46 if ( empty($section->post_name) && in_array( $section->post_status, array( 'draft' ) ) ) { 47 $section->post_name = sanitize_title($section->post_title, $section->ID); 48 $wpdb->update( $wpdb->posts, array( 'post_name' => $section->post_name ), array( 'ID' => $section->ID ) ); 44 if ( (strcmp($post_type, af_namespace() . '_' . \ArticleForge\Constants::SummaryPostType) == 0) || 45 (strcmp($post_type, af_namespace() . '_' . \ArticleForge\Constants::ContentPostType) == 0) ) { 46 $article = get_post($post_id); 47 if ( empty($article->post_name) && in_array( $article->post_status, array( 'draft' ) ) ) { 48 $article->post_name = sanitize_title($article->post_title, $article->ID); 49 $wpdb->update( $wpdb->posts, array( 'post_name' => $article->post_name ), array( 'ID' => $article->ID ) ); 49 50 } 50 51 } -
article-forge/trunk/ArticleForge/Constants.php
r729157 r734086 6 6 const PackageName = 'Article Forge'; 7 7 8 const Version = '1.1. 2';8 const Version = '1.1.3'; 9 9 10 10 const PackagePrefix = 'articleforge'; -
article-forge/trunk/ArticleForge/Content.php
r718377 r734086 34 34 35 35 public function pre_get_posts( $query = '' ) { 36 if ( $query->get( 'suppress_filters' )) 37 return; 38 $query->set( 'posts_per_page', articleforge()->options->summaries_per_page ); 36 // When previewing sections, WP does not validate the post id but blindly assumes it's for the main query 37 // Turn it off here but reactivate when rendering sections 38 if ( is_preview() && $query->get('section') ) { 39 //if (( $query->get('post_type') == af_namespace() . '_' . \ArticleForge\Constants::SummyPostType) && 40 $query->is_preview = 0; 41 } 42 /*if ( is_home() ) { 43 $query->set( 'posts_per_page', 1 ); 44 }*/ 45 if ( is_post_type_archive() ) { 46 $query->set( 'posts_per_page', articleforge()->options->summaries_per_page ); 47 } 39 48 } 40 49 -
article-forge/trunk/ArticleForge/Content/ActionMap.php
r718549 r734086 18 18 if ( !defined( 'ABSPATH' ) ) exit; 19 19 20 import('ArticleForge.Constants'); 21 20 22 /** 21 23 * … … 36 38 37 39 public static function pre_get_posts( $wp_query ) { 38 if ( is_admin() || ! $wp_query->is_main_query() )40 if ( is_admin() || ! $wp_query->is_main_query() || $wp_query->get( 'suppress_filters' ) ) 39 41 return; 40 42 41 if (!articleforge()->validate_request($wp_query)) return; 42 if ( is_home() ) articleforge()->home($wp_query); 43 // (bool)$query->get('is_archive') 44 if ( is_post_type_archive() && is_post_type_namespace(af_namespace())) { 43 if ( is_home() ) { 44 if ( articleforge()->options->show_on_home == 'true' ) 45 $wp_query->set('post_type', af_namespace() . '_' . \ArticleForge\Constants::SummaryPostType); 46 } elseif( is_category() || is_tag() ) { 47 $post_type = get_query_var('post_type'); 48 if(!$post_type) { 49 $post_type = $wp_query->get('post_type'); 50 if (is_array($post_type)) { 51 array_push($post_type, af_namespace() . '_' . \ArticleForge\Constants::SummaryPostType); 52 } else { 53 $post_type = array($post_type, af_namespace() . '_' . \ArticleForge\Constants::SummaryPostType); 54 } 55 $wp_query->set('post_type', $post_type); 56 } 57 return; 58 } 59 // should just do is_post_type_namespace(af_namespace()) 60 if ( is_post_type_namespace(af_namespace()) ) { 61 if (!articleforge()->validate_request($wp_query)) return; 45 62 do_action( af_namespace() . '_pre_get_posts', $wp_query ); 46 63 } -
article-forge/trunk/content/default/article-section.php
r725136 r734086 7 7 </div> 8 8 <div class="articleforge-section-content"> 9 <?php echo do_shortcode($content->post_content); ?>9 <?php echo apply_filters('the_content', $content->post_content); ?> 10 10 </div> 11 11 </div> -
article-forge/trunk/content/default/single-summary.php
r728624 r734086 12 12 13 13 $section = get_query_var(articleforge()->options->section_slug); 14 $preview = get_query_var('preview') == 'true'; 14 $preview = array_key_exists('preview', $_GET) && ($_GET['preview'] == 'true') && 15 is_user_logged_in() && current_user_can('read', $post->ID); 16 15 17 // Let's default to showing the first section if no section or invalid section 16 18 // if section is specified, follow article options unless showtocalways is false and showallsections is true … … 24 26 ($has_section && $always_show_toc); 25 27 $show_all_sections = !$has_section && $show_all_sections; 28 29 function af_check_preview($post_id = 0) { 30 if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) { 31 $id = (int) $_GET['preview_id']; 32 if ($id != $post_id) return false; 33 34 if ( false == wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) ) 35 wp_die( __('You do not have permission to preview drafts.') ); 36 return true; 37 } 38 return false; 39 } 26 40 27 41 function af_section_url($content, $preview) { … … 43 57 </div> 44 58 <div class="articleforge-heading-title"> 45 <?php echo $post->post_title; ?>59 <?php the_title(); ?> 46 60 </div> 47 61 <div class="articleforge-heading-summary"> 48 <p><?php echo do_shortcode($post->post_content);?></p>62 <p><?php the_content(); /*echo apply_filters('the_content', $post->post_content)*/?></p> 49 63 </div> 50 64 </div> 51 65 <?php 52 66 $statuses = array('publish'); 53 if ( is_user_logged_in() && ($post->post_author == get_current_user_id()) &&$preview) array_push($statuses, 'draft');67 if ($preview) array_push($statuses, 'draft'); 54 68 // Don't tromp on WordPress globals 55 69 $contents = new \WP_Query( … … 63 77 ) 64 78 ); 65 if ($show_toc ) {79 if ($show_toc && ($contents->found_posts != 0)) { 66 80 ?> 67 81 <div class="articleforge-toc"> … … 95 109 } else if ($has_section) { 96 110 if ($content->post_name == $section) { 111 ?><input type="hidden" id="section_name" name="section_name" value="<?php echo $section; ?>"/><?php 112 if ($preview && 113 ((($content->post_status == 'publish') && af_check_preview($content->ID)) || ($content->status == 'draft'))) 114 $content = _set_preview($content); 97 115 \ArticleForge\Content::load('article', 'section'); 98 116 break; … … 105 123 <div class="articleforge-nav"> 106 124 <?php 107 if ( $last_content) {125 if (isset($last_content)) { 108 126 $content = $last_content; 109 127 ?> -
article-forge/trunk/functions.php
r718549 r734086 51 51 else if (is_post_type_archive()) return 'archive'; 52 52 else if (is_home()) return 'home'; 53 else if (is_category()) return 'category'; 53 54 } 54 55 -
article-forge/trunk/main.php
r729157 r734086 7 7 * Author: Anthony Wells 8 8 * Author URI: http://www.bytewisemcu.org/profile/awells 9 * Version: 1.1. 29 * Version: 1.1.3 10 10 * Text Domain: articleforge 11 11 * Domain Path: /languages/ -
article-forge/trunk/readme.txt
r729157 r734086 4 4 Requires at least: 3.0.1 5 5 Tested up to: 3.5.1 6 Stable tag: 1.1. 26 Stable tag: 1.1.3 7 7 License: GPLv2 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 28 28 == Installation == 29 29 30 Article Forge is simple to install and use with WordPress. The only requirement is a shift in perspective in how WordPress organizes and generates pages. The underlying engine for the Article Forge plugin makes a clear distinction between the concept of WordPress templates and that of generated content inside the theme's displayable content area. Generally speaking, WordPress requires the site maintainer to create separate template pages for each custom post type under the theme's template directory; not the plugin directory. These templates almost always leave the template's layout intact with changes made only in the content area. Seeking to provide a more practical and persistant approach, the Article Forge plugin provides a shared hook that generates the content for the template. In this way the user is not required to copy source html from the plugin directory and edit it.30 Article Forge is simple to install and use with WordPress. The only requirement is a shift in perspective in how WordPress organizes and generates pages. The underlying engine for the Article Forge plugin makes a clear distinction between the concept of WordPress templates and that of generated content inside the theme's displayable content area. Generally speaking, WordPress requires the site maintainer to create separate template pages for each custom post type under the theme's template directory; not the plugin directory. These templates almost always leave the template's layout intact with changes made only in the content area. Seeking to provide a more practical and persistant approach, the Article Forge plugin provides a shared hook that generates the content for the template. In this way the user is not required to copy source html from the plugin directory and edit it. 31 31 32 To utilize this feature, open 'archive.php' and 'single.php' in WP's built-in editor, back-up and remove the existing post content generation area (usually denoted by `<div id="content>`) and replace it with 32 There are various ways to utilize this feature with the simplest approach for those who wish to use Article Forge with other content types (this includes post and custom) is to do it the 'WordPress' way. 33 * Copy 'single.php' and 'archive.php' located under your Themes working directory to 'single-articleforge_summary.php' and 'archive-articleforge_summary.php' respectively. 34 * Edit these files using the WP built-in editor under the Admin Appearance menu. Remove the existing post content generation area (usually denoted by `<div id="content>`) and replace it with 33 35 34 36 `<?php regwptk_generate_content(); ?>` 35 37 38 The other approach for users who only wish to use Article Forge for site content can modify 'single.php' and 'archive.php' directly while those wishing to use Article Forge with WordPress Posts can copy those files to 'single-post.php' and 'archive-post.php' before editing. (For those brave souls who are interested in testing a new approach to content generation via plugins with custom post types in WordPress should contact me via <>.) 39 36 40 Article Forge will generate the content based on the post type of the post(s) being displayed and the context of the request (ie. archive, single, search). If it detects that the post type is not one of its own registered types, it will defer back to the WordPress template engine to generate the page. 37 41 38 No CSS is provided for the generated HTML. It is suggested that users copy the contents of the 'default' directory under 'content' to a parallel directory under 'content'. (You can specify that content be served from this directory by editing the appropriate option under the Article Forge settings page.) Note that any CSS or JS files that you create under the css and js directories respectively are automatically included in Article Forge content pages. Ample class tags are provided in the HTML for your customization needs.42 Basic CSS is provided for the generated HTML with ample class tags provided for your customization needs. It is suggested that users copy the contents of the 'default' directory under the Article Forge plugin 'content' directory to a parallel directory under 'content'. (You can specify that content be served from this directory by editing the appropriate option under the Article Forge settings page.) Note that any CSS or JS files that you place under the css and js directories are automatically included in Article Forge content pages. 39 43 40 44 Slugs designating the articles and article areas in the URL are defined in the Article Forge Settings page under the admin area. They are respectively 'articles' and 'article' by default. There are many other options avaible that control how the plugin behaves. You are encouraged to become familiar with these options. 41 45 42 46 == Frequently Asked Questions == 47 48 = Can I use Article Forge without having to modify my existing template files to support the psuedo WP Registry ToolKit functions? = 49 50 Yes, you can. Copy your existing 'single.php' and 'archive.php' located under your working theme directory to 'single-articleforge_summary' and 'archive-articleforge_summary' respectively. (I may consider adding a management feature to do this automatically if there is sufficient interest.) Edit these files using the WP built-in editor under the Admin Appearance menu. Remove the existing 'content' generation area and replace it with `regwptk_generate_content();` per the installation instructions. 43 51 44 52 = I really like the Article Forge plugin, but there are some additional features I would like to see. Where can I make requests? = … … 57 65 58 66 == Changelog == 67 68 = 1.1.3 = 69 * Added Category and Tag support 70 * Added WP type preview support to both articles and sections 71 * Moved to WP macros to render content where appropriate 72 * Updated Installation instructions 73 * Create post_name for draft Article Summaries 59 74 60 75 = 1.1.2 =
Note: See TracChangeset
for help on using the changeset viewer.