Plugin Directory

Changeset 734086


Ignore:
Timestamp:
06/29/2013 06:08:20 PM (13 years ago)
Author:
borgboy
Message:

Added category and tag support

Location:
article-forge/trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • article-forge/trunk/ArticleForge.php

    r729145 r734086  
    174174                        $cquery->next_post();
    175175                        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)
    177178                                && (array_key_exists('preview', $_GET) && ($_GET['preview'] == 'true'))) {
    178179                                $section = $cquery->post;
     
    187188                    if (isset($article)) {
    188189                        $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                        }
    191195                        wp_safe_redirect($url);
    192196                        exit();
     
    214218                    if (isset($post_post)) {
    215219                        $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');
    218222                        // use author id and _GET to determine if we should allow draft to $statuses
    219223                        // get section from post id and section name
     
    238242        }
    239243        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         }
    248244    }
    249245
  • article-forge/trunk/ArticleForge/Admin.php

    r728624 r734086  
    203203        $post_parent = $post->post_parent == 0 ? (array_key_exists('post_parent', $_GET) ? $_GET['post_parent'] : 0 ) : $post->post_parent;
    204204        $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         }
    209205?>
    210206<input type="hidden" id="parent_id" name="parent_id" value="<?php echo $post_parent; ?>"/>
     
    358354        if (!array_key_exists('post_parent', $_GET)) {
    359355            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.');
    360364        }
    361365    }
  • article-forge/trunk/ArticleForge/Admin/Hacks.php

    r728458 r734086  
    3737
    3838    public static function insert_post($post_id) {
    39         // ArticleForge has checks in place to prevent unauthorized viewing of draft articles.
     39        // ArticleForge doesn't populate post_name for draft articles which prevents unauthorized viewing of these articles.
    4040        // Populate post_name to allow previewing of draft articles.
    4141        global $wpdb;
    4242        $post_type = get_post_type( $post_id );
    4343        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 ) );
    4950            }
    5051        }
  • article-forge/trunk/ArticleForge/Constants.php

    r729157 r734086  
    66    const PackageName     = 'Article Forge';
    77
    8     const Version         = '1.1.2';
     8    const Version         = '1.1.3';
    99
    1010    const PackagePrefix   = 'articleforge';
  • article-forge/trunk/ArticleForge/Content.php

    r718377 r734086  
    3434
    3535    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        }
    3948    }
    4049
  • article-forge/trunk/ArticleForge/Content/ActionMap.php

    r718549 r734086  
    1818if ( !defined( 'ABSPATH' ) ) exit;
    1919
     20import('ArticleForge.Constants');
     21
    2022/**
    2123 *
     
    3638
    3739    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' ) )
    3941            return;
    4042
    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;
    4562            do_action( af_namespace() . '_pre_get_posts', $wp_query );
    4663        }
  • article-forge/trunk/content/default/article-section.php

    r725136 r734086  
    77    </div>
    88    <div class="articleforge-section-content">
    9         <?php echo do_shortcode($content->post_content); ?>
     9        <?php echo apply_filters('the_content', $content->post_content); ?>
    1010    </div>
    1111</div>
  • article-forge/trunk/content/default/single-summary.php

    r728624 r734086  
    1212
    1313$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
    1517// Let's default to showing the first section if no section or invalid section
    1618// if section is specified, follow article options unless showtocalways is false and showallsections is true
     
    2426($has_section && $always_show_toc);
    2527$show_all_sections = !$has_section && $show_all_sections;
     28
     29function 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}
    2640
    2741function af_section_url($content, $preview) {
     
    4357        </div>
    4458        <div class="articleforge-heading-title">
    45         <?php echo $post->post_title; ?>
     59        <?php the_title(); ?>
    4660        </div>
    4761        <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>
    4963        </div>
    5064    </div>
    5165<?php
    5266    $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');
    5468    // Don't tromp on WordPress globals
    5569    $contents = new \WP_Query(
     
    6377        )
    6478    );
    65     if ($show_toc) {
     79    if ($show_toc && ($contents->found_posts != 0)) {
    6680?>
    6781<div class="articleforge-toc">
     
    95109        } else if ($has_section) {
    96110            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);
    97115                \ArticleForge\Content::load('article', 'section');
    98116                break;
     
    105123    <div class="articleforge-nav">
    106124<?php
    107         if ($last_content) {
     125        if (isset($last_content)) {
    108126            $content = $last_content;
    109127?>
  • article-forge/trunk/functions.php

    r718549 r734086  
    5151    else if (is_post_type_archive()) return 'archive';
    5252    else if (is_home()) return 'home';
     53    else if (is_category()) return 'category';
    5354}
    5455
  • article-forge/trunk/main.php

    r729157 r734086  
    77 * Author:      Anthony Wells
    88 * Author URI:  http://www.bytewisemcu.org/profile/awells
    9  * Version:     1.1.2
     9 * Version:     1.1.3
    1010 * Text Domain: articleforge
    1111 * Domain Path: /languages/
  • article-forge/trunk/readme.txt

    r729157 r734086  
    44Requires at least: 3.0.1
    55Tested up to: 3.5.1
    6 Stable tag: 1.1.2
     6Stable tag: 1.1.3
    77License: GPLv2
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2828== Installation ==
    2929
    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.
     30Article 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.
    3131
    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
     32There 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
    3335
    3436     `<?php regwptk_generate_content(); ?>`
    3537
     38The 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
    3640Article 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.
    3741
    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.
     42Basic 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.
    3943
    4044Slugs 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.
    4145
    4246== 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
     50Yes, 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.
    4351
    4452= I really like the Article Forge plugin, but there are some additional features I would like to see.  Where can I make requests? =
     
    5765
    5866== 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
    5974
    6075= 1.1.2 =
Note: See TracChangeset for help on using the changeset viewer.