Quantcast
Viewing all articles
Browse latest Browse all 2443

toastyanorak on "Error 500 Not Resolving"

@justingreerbbi

Here is the code, hopefully you can find an error that might solve this:

<?php
/**
 * The Black and White Grouped Content
 *
 * This module handles the grouping of a set of articles under a
 * taxonomy of your choosing.
 *
 * By default, groupings of posts will be selected using the given
 * taxonomy, and then additional posts will be drawn to populate
 * each of those groups with more posts.
 */
class Grouped_Content {

    /**
     * Instantiate.
     *
     * All custom functionality will be hooked into the "init" action.
     *
     * @static
     * @access public
     * @since 3.1
     */
    public static function setup() {
        add_action( 'init', array( __CLASS__, 'init' ), 30 );
    }

    /**
     * Conditionally hook into WordPress.
     *
     * Theme must declare that they support this module by adding
     * add_theme_support( 'grouped-content' ); during after_setup_theme.
     *
     * If no theme support is found there is no need to hook into WordPress.
     * We'll just return early instead.
     *
     * @static
     * @access public
     * @since  3.1
     */
    public static function init() {
	     $theme_support = get_theme_support( 'grouped-content' );

        // Return early if theme does not support Grouped Content.
        if ( ! $theme_support ) {
            return;
        }

        /*
         * An array of named arguments must be passed as the second parameter
         * of add_theme_support().
         */
        if ( ! isset( $theme_support[0] ) ) {
            return;
        }

        // Return early if "grouped_content_filter" has not been defined.
        if ( ! isset( $theme_support[0]['grouped_content_filter'] ) ) {
            return;
        }

        $filter = $theme_support[0]['grouped_content_filter'];

        add_filter( $filter, array( __CLASS__, 'get_grouped_posts'  ) );
    }

    /**
     * Get grouped posts.
     *
     * @static
     * @access public
     * @since 3.1
     *
     * @return array Array of grouped posts.
     */

    public static function get_grouped_posts() {
        $grouped_ids = self::get_grouped_post_ids();

        $grouped_posts = array_map( array( __CLASS__, 'get_posts_by_ids' *), $grouped_ids );

        return $grouped_posts;
    }

     /** Get grouped post IDs
     *
     * This function will return the an array containing the
     * post IDs of all grouped posts.
     *
     * @static
     * @access public
     * @since 3.1
     *
     * @return array Array of post IDs.
     */
    public static function get_grouped_post_ids() {

        // Get the posts.
        $posts = new WP_Query( array(
            'author'      => get_query_var( 'author' ),
            'cat'         => get_query_var( 'cat' ),
            'tag'         => get_query_var( 'tag' ),
            'tax_query'   => get_query_var( 'tax_query' ),
            'year'        => get_query_var( 'year' ),
            'monthnum'    => get_query_var( 'monthnum' ),
            'day'         => get_query_var( 'day' ),
           'post_type'   => get_query_var( 'post_type' )
            ) );

        $posts = $posts->get_posts();

        // Loop over all the posts, and start sorting them by tag.
        $posts_by_tag = array();
        $post_ids = array();

        foreach ( $posts as $post ) {
            $tags = get_the_tags( $post->ID );
            if ( empty( $tags ) )
                continue;

            $post_ids[] = $post->ID;

            // Loop over each tag and add it to our index.
            foreach ( $tags as $tag ) {
                if ( $posts_by_tag[ $tag->term_id ] )
                    $posts_by_tag[ $tag->term_id ][] = $post->ID;
                else
                    $posts_by_tag[ $tag->term_id ] = array( $post->ID );
            }
        }

         // Create the final array.
         $grouped = array();

        foreach ( $posts_by_tag as $tag => $posts ) {

             // Sanitize the posts by removing any that have already been * included.
             $sanitized_posts = array_intersect( $posts, $post_ids );
             $post_ids = array_diff( $post_ids, $sanitized_posts );*

             $grouped[ $tag ] = $sanitized_posts;

         }

         return $grouped;
     }

    /** Get an array of post objects given an array of post IDs.
     *
     * This is used as an auxilary function for the array_mapping
     * done in Grouped_Content::get_grouped_posts().
     */
      @static
      @access public
      @since 3.1

      @param Array $post_ids
      @return Array Array of posts.

     public static function get_posts_by_ids( $post_ids ) {
         return get_posts( array(
             'include'        => $post_ids,
             'posts_per_page' => count( $post_ids )
             ) );
     }

 } // Grouped_Content

Grouped_Content::setup();
?>

Viewing all articles
Browse latest Browse all 2443

Trending Articles