Version Description
- Fixes projects page not loading - please resave permalinks after updating!
Download this release
Release Info
| Developer | jeffikus |
| Plugin | |
| Version | 1.5.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.2 to 1.5.0
- classes/class-projects-admin.php +15 -12
- classes/class-projects-frontend.php +11 -1
- classes/class-projects-query.php +420 -0
- projects-template.php +6 -2
- projects.php +4 -4
- readme.txt +11 -4
classes/class-projects-admin.php
CHANGED
|
@@ -313,8 +313,9 @@ class Projects_Admin {
|
|
| 313 |
$html .= '</td><tr/>' . "\n";
|
| 314 |
break;
|
| 315 |
case 'editor':
|
|
|
|
| 316 |
ob_start();
|
| 317 |
-
wp_editor( $data, $k,
|
| 318 |
$field = ob_get_contents();
|
| 319 |
ob_end_clean();
|
| 320 |
$html .= '<tr valign="top"><th scope="row"><label for="' . esc_attr( $k ) . '">' . $v['name'] . '</label></th><td>' . $field . "\n";
|
|
@@ -570,20 +571,22 @@ class Projects_Admin {
|
|
| 570 |
|
| 571 |
wp_enqueue_style( 'projects-admin', $this->assets_url . '/css/admin.css', array(), '1.0.0' );
|
| 572 |
|
| 573 |
-
if ( $pagenow == 'post.php' && get_post_type() == $this->post_type ) {
|
| 574 |
wp_enqueue_script( 'projects-admin', $this->assets_url . '/js/admin.js', array( 'jquery' ), '1.0.0', true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
}
|
| 576 |
|
| 577 |
-
wp_localize_script( 'projects-admin', 'woo_projects_admin',
|
| 578 |
-
array(
|
| 579 |
-
'gallery_title' => __( 'Add Images to Project Gallery', 'projects-by-woothemes' ),
|
| 580 |
-
'gallery_button' => __( 'Add to gallery', 'projects-by-woothemes' ),
|
| 581 |
-
'delete_image' => __( 'Delete image', 'projects-by-woothemes' ),
|
| 582 |
-
'default_title' => __( 'Upload', 'projects-by-woothemes' ),
|
| 583 |
-
'default_button' => __( 'Select this', 'projects-by-woothemes' ),
|
| 584 |
-
)
|
| 585 |
-
);
|
| 586 |
-
|
| 587 |
} // End enqueue_admin_styles()
|
| 588 |
|
| 589 |
/**
|
| 313 |
$html .= '</td><tr/>' . "\n";
|
| 314 |
break;
|
| 315 |
case 'editor':
|
| 316 |
+
$editor_arguments = array( 'media_buttons' => false, 'textarea_rows' => 10 );
|
| 317 |
ob_start();
|
| 318 |
+
wp_editor( $data, $k, apply_filters( 'projects_editor_arguments' , $editor_arguments ) );
|
| 319 |
$field = ob_get_contents();
|
| 320 |
ob_end_clean();
|
| 321 |
$html .= '<tr valign="top"><th scope="row"><label for="' . esc_attr( $k ) . '">' . $v['name'] . '</label></th><td>' . $field . "\n";
|
| 571 |
|
| 572 |
wp_enqueue_style( 'projects-admin', $this->assets_url . '/css/admin.css', array(), '1.0.0' );
|
| 573 |
|
| 574 |
+
if ( ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) && get_post_type() == $this->post_type ) {
|
| 575 |
wp_enqueue_script( 'projects-admin', $this->assets_url . '/js/admin.js', array( 'jquery' ), '1.0.0', true );
|
| 576 |
+
|
| 577 |
+
|
| 578 |
+
wp_localize_script( 'projects-admin', 'woo_projects_admin',
|
| 579 |
+
array(
|
| 580 |
+
'gallery_title' => __( 'Add Images to Project Gallery', 'projects-by-woothemes' ),
|
| 581 |
+
'gallery_button' => __( 'Add to gallery', 'projects-by-woothemes' ),
|
| 582 |
+
'delete_image' => __( 'Delete image', 'projects-by-woothemes' ),
|
| 583 |
+
'default_title' => __( 'Upload', 'projects-by-woothemes' ),
|
| 584 |
+
'default_button' => __( 'Select this', 'projects-by-woothemes' ),
|
| 585 |
+
)
|
| 586 |
+
);
|
| 587 |
+
|
| 588 |
}
|
| 589 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
} // End enqueue_admin_styles()
|
| 591 |
|
| 592 |
/**
|
classes/class-projects-frontend.php
CHANGED
|
@@ -22,6 +22,14 @@ class Projects_Frontend {
|
|
| 22 |
*/
|
| 23 |
public $template_loader;
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
/**
|
| 26 |
* Constructor function.
|
| 27 |
*
|
|
@@ -33,6 +41,8 @@ class Projects_Frontend {
|
|
| 33 |
require_once( 'class-projects-template-loader.php' );
|
| 34 |
$this->template_loader = new Projects_Template_Loader();
|
| 35 |
add_filter( 'template_include', array( $this->template_loader, 'template_loader' ) );
|
|
|
|
|
|
|
| 36 |
} // End __construct()
|
| 37 |
} // End Class
|
| 38 |
-
?>
|
| 22 |
*/
|
| 23 |
public $template_loader;
|
| 24 |
|
| 25 |
+
/**
|
| 26 |
+
* Instance of Projects_Query.
|
| 27 |
+
* @access public
|
| 28 |
+
* @since 1.5.0
|
| 29 |
+
* @var object
|
| 30 |
+
*/
|
| 31 |
+
public $projects_query;
|
| 32 |
+
|
| 33 |
/**
|
| 34 |
* Constructor function.
|
| 35 |
*
|
| 41 |
require_once( 'class-projects-template-loader.php' );
|
| 42 |
$this->template_loader = new Projects_Template_Loader();
|
| 43 |
add_filter( 'template_include', array( $this->template_loader, 'template_loader' ) );
|
| 44 |
+
require_once( 'class-projects-query.php' );
|
| 45 |
+
$this->projects_query = new Projects_Query();
|
| 46 |
} // End __construct()
|
| 47 |
} // End Class
|
| 48 |
+
?>
|
classes/class-projects-query.php
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* WooThemes Projects Query Class
|
| 6 |
+
*
|
| 7 |
+
* All functionality pertaining to the projects WP query modifications.
|
| 8 |
+
*
|
| 9 |
+
* @package WordPress
|
| 10 |
+
* @subpackage Projects_Query
|
| 11 |
+
* @category Plugin
|
| 12 |
+
* @author Jeffikus
|
| 13 |
+
* @since 1.5.0
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
class Projects_Query {
|
| 17 |
+
/**
|
| 18 |
+
* NOTE - Ported from WooCommerce in order to
|
| 19 |
+
* correctly modify the query object.
|
| 20 |
+
* @since 1.5.0
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
/** @public array Query vars to add to wp */
|
| 24 |
+
public $query_vars = array();
|
| 25 |
+
|
| 26 |
+
/** @public array Unfiltered project ids - refactor 1.5.1 */
|
| 27 |
+
public $unfiltered_project_ids = array();
|
| 28 |
+
|
| 29 |
+
/** @public array Filtered project ids - refactor 1.5.1 */
|
| 30 |
+
public $filtered_project_ids = array();
|
| 31 |
+
|
| 32 |
+
/** @public array Filtered project ids - refactor 1.5.1 */
|
| 33 |
+
public $filtered_project_ids_for_taxonomy = array();
|
| 34 |
+
|
| 35 |
+
/** @public array project IDs that match filters */
|
| 36 |
+
public $post__in = array();
|
| 37 |
+
|
| 38 |
+
/** @public array|string The meta query for the page */
|
| 39 |
+
public $meta_query = '';
|
| 40 |
+
|
| 41 |
+
/** @public array Post IDs - refactor 1.5.1 */
|
| 42 |
+
public $layered_nav_post__in = array();
|
| 43 |
+
|
| 44 |
+
/** @public array Stores post IDs - refactor 1.5.1 */
|
| 45 |
+
public $layered_nav_project_ids = array();
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Constructor function.
|
| 49 |
+
*
|
| 50 |
+
* @access public
|
| 51 |
+
* @since 1.5.0
|
| 52 |
+
* @return void
|
| 53 |
+
*/
|
| 54 |
+
public function __construct () {
|
| 55 |
+
if ( ! is_admin() ) {
|
| 56 |
+
add_filter( 'query_vars', array( $this, 'add_query_vars'), 0 );
|
| 57 |
+
add_action( 'parse_request', array( $this, 'parse_request'), 0 );
|
| 58 |
+
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
| 59 |
+
add_filter( 'the_posts', array( $this, 'the_posts' ), 11, 2 );
|
| 60 |
+
add_action( 'wp', array( $this, 'remove_project_query' ) );
|
| 61 |
+
}
|
| 62 |
+
$this->init_query_vars();
|
| 63 |
+
} // End __construct()
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Init query vars by loading options.
|
| 67 |
+
*/
|
| 68 |
+
public function init_query_vars() {
|
| 69 |
+
// Query vars to add to WP
|
| 70 |
+
$this->query_vars = array();
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* add_query_vars function.
|
| 75 |
+
*
|
| 76 |
+
* @access public
|
| 77 |
+
* @param array $vars
|
| 78 |
+
* @return array
|
| 79 |
+
*/
|
| 80 |
+
public function add_query_vars( $vars ) {
|
| 81 |
+
foreach ( $this->query_vars as $key => $var ) {
|
| 82 |
+
$vars[] = $key;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
return $vars;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Get query vars
|
| 90 |
+
*
|
| 91 |
+
* @return array
|
| 92 |
+
*/
|
| 93 |
+
public function get_query_vars() {
|
| 94 |
+
return $this->query_vars;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* Parse the request and look for query vars - endpoints may not be supported
|
| 99 |
+
*/
|
| 100 |
+
public function parse_request() {
|
| 101 |
+
global $wp;
|
| 102 |
+
|
| 103 |
+
// Map query vars to their keys, or get them if endpoints are not supported
|
| 104 |
+
foreach ( $this->query_vars as $key => $var ) {
|
| 105 |
+
if ( isset( $_GET[ $var ] ) ) {
|
| 106 |
+
$wp->query_vars[ $key ] = $_GET[ $var ];
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
elseif ( isset( $wp->query_vars[ $var ] ) ) {
|
| 110 |
+
$wp->query_vars[ $key ] = $wp->query_vars[ $var ];
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* Hook into pre_get_posts to do the main project query
|
| 117 |
+
*
|
| 118 |
+
* @param mixed $q query object
|
| 119 |
+
*/
|
| 120 |
+
public function pre_get_posts( $q ) {
|
| 121 |
+
// We only want to affect the main query
|
| 122 |
+
if ( ! $q->is_main_query() ) {
|
| 123 |
+
return;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
// Fix for verbose page rules
|
| 127 |
+
if ( $GLOBALS['wp_rewrite']->use_verbose_page_rules && isset( $q->queried_object_id ) && $q->queried_object_id === projects_get_page_id( 'projects' ) ) {
|
| 128 |
+
$q->set( 'post_type', 'project' );
|
| 129 |
+
$q->set( 'page', '' );
|
| 130 |
+
$q->set( 'pagename', '' );
|
| 131 |
+
|
| 132 |
+
// Fix conditional Functions
|
| 133 |
+
$q->is_archive = true;
|
| 134 |
+
$q->is_post_type_archive = true;
|
| 135 |
+
$q->is_singular = false;
|
| 136 |
+
$q->is_page = false;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
// Fix for endpoints on the homepage
|
| 140 |
+
if ( $q->is_home() && 'page' == get_option('show_on_front') && get_option('page_on_front') != $q->get('page_id') ) {
|
| 141 |
+
$_query = wp_parse_args( $q->query );
|
| 142 |
+
if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->query_vars ) ) ) {
|
| 143 |
+
$q->is_page = true;
|
| 144 |
+
$q->is_home = false;
|
| 145 |
+
$q->is_singular = true;
|
| 146 |
+
|
| 147 |
+
$q->set( 'page_id', get_option('page_on_front') );
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
// When orderby is set, WordPress shows posts. Get around that here.
|
| 152 |
+
if ( $q->is_home() && 'page' == get_option('show_on_front') && get_option('page_on_front') == projects_get_page_id( 'projects' ) ) {
|
| 153 |
+
$_query = wp_parse_args( $q->query );
|
| 154 |
+
if ( empty( $_query ) || ! array_diff( array_keys( $_query ), array( 'preview', 'page', 'paged', 'cpage', 'orderby' ) ) ) {
|
| 155 |
+
$q->is_page = true;
|
| 156 |
+
$q->is_home = false;
|
| 157 |
+
$q->set( 'page_id', get_option('page_on_front') );
|
| 158 |
+
$q->set( 'post_type', 'project' );
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
// Special check for the project archive on front
|
| 163 |
+
if ( $q->is_page() && 'page' == get_option( 'show_on_front' ) && $q->get('page_id') == projects_get_page_id( 'projects' ) ) {
|
| 164 |
+
|
| 165 |
+
// This is a front-page projects
|
| 166 |
+
$q->set( 'post_type', 'project' );
|
| 167 |
+
$q->set( 'page_id', '' );
|
| 168 |
+
if ( isset( $q->query['paged'] ) ) {
|
| 169 |
+
$q->set( 'paged', $q->query['paged'] );
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
// Define a variable so we know this is the front page projects later on
|
| 173 |
+
define( 'PROJECT_IS_ON_FRONT', true );
|
| 174 |
+
|
| 175 |
+
// Get the actual WP page to avoid errors and let us use is_front_page()
|
| 176 |
+
// This is hacky but works. Awaiting http://core.trac.wordpress.org/ticket/21096
|
| 177 |
+
global $wp_post_types;
|
| 178 |
+
|
| 179 |
+
$project_page = get_post( projects_get_page_id( 'projects' ) );
|
| 180 |
+
|
| 181 |
+
$wp_post_types['project']->ID = $project_page->ID;
|
| 182 |
+
$wp_post_types['project']->post_title = $project_page->post_title;
|
| 183 |
+
$wp_post_types['project']->post_name = $project_page->post_name;
|
| 184 |
+
$wp_post_types['project']->post_type = $project_page->post_type;
|
| 185 |
+
$wp_post_types['project']->ancestors = get_ancestors( $project_page->ID, $project_page->post_type );
|
| 186 |
+
|
| 187 |
+
// Fix conditional Functions like is_front_page
|
| 188 |
+
$q->is_singular = false;
|
| 189 |
+
$q->is_post_type_archive = true;
|
| 190 |
+
$q->is_archive = true;
|
| 191 |
+
$q->is_page = true;
|
| 192 |
+
|
| 193 |
+
// Fix WP SEO
|
| 194 |
+
if ( class_exists( 'WPSEO_Meta' ) ) {
|
| 195 |
+
add_filter( 'wpseo_metadesc', array( $this, 'wpseo_metadesc' ) );
|
| 196 |
+
add_filter( 'wpseo_metakey', array( $this, 'wpseo_metakey' ) );
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
// Only apply to project categories, the project post archive, the projects page, project tags, and project attribute taxonomies
|
| 200 |
+
} elseif ( ! $q->is_post_type_archive( 'project' ) && ! $q->is_tax( get_object_taxonomies( 'project' ) ) ) {
|
| 201 |
+
return;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
$this->project_query( $q );
|
| 205 |
+
|
| 206 |
+
if ( is_search() ) {
|
| 207 |
+
add_filter( 'posts_where', array( $this, 'search_post_excerpt' ) );
|
| 208 |
+
add_filter( 'wp', array( $this, 'remove_posts_where' ) );
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
// We're on a projects page so queue the get_projects_in_view function
|
| 212 |
+
add_action( 'wp', array( $this, 'get_projects_in_view' ), 2);
|
| 213 |
+
|
| 214 |
+
// And remove the pre_get_posts hook
|
| 215 |
+
$this->remove_project_query();
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* search_post_excerpt function.
|
| 220 |
+
*
|
| 221 |
+
* @access public
|
| 222 |
+
* @param string $where (default: '')
|
| 223 |
+
* @return string (modified where clause)
|
| 224 |
+
*/
|
| 225 |
+
public function search_post_excerpt( $where = '' ) {
|
| 226 |
+
global $wp_the_query;
|
| 227 |
+
|
| 228 |
+
// If this is not a WC Query, do not modify the query
|
| 229 |
+
if ( empty( $wp_the_query->query_vars['projects_query'] ) || empty( $wp_the_query->query_vars['s'] ) )
|
| 230 |
+
return $where;
|
| 231 |
+
|
| 232 |
+
$where = preg_replace(
|
| 233 |
+
"/post_title\s+LIKE\s*(\'\%[^\%]+\%\')/",
|
| 234 |
+
"post_title LIKE $1) OR (post_excerpt LIKE $1", $where );
|
| 235 |
+
|
| 236 |
+
return $where;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
/**
|
| 240 |
+
* wpseo_metadesc function.
|
| 241 |
+
* Hooked into wpseo_ hook already, so no need for function_exist
|
| 242 |
+
*
|
| 243 |
+
* @access public
|
| 244 |
+
* @return string
|
| 245 |
+
*/
|
| 246 |
+
public function wpseo_metadesc() {
|
| 247 |
+
return WPSEO_Meta::get_value( 'metadesc', projects_get_page_id('projects') );
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* wpseo_metakey function.
|
| 252 |
+
* Hooked into wpseo_ hook already, so no need for function_exist
|
| 253 |
+
*
|
| 254 |
+
* @access public
|
| 255 |
+
* @return string
|
| 256 |
+
*/
|
| 257 |
+
public function wpseo_metakey() {
|
| 258 |
+
return WPSEO_Meta::get_value( 'metakey', projects_get_page_id('projects') );
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
* Hook into the_posts to do the main project query if needed - relevanssi compatibility
|
| 263 |
+
*
|
| 264 |
+
* @access public
|
| 265 |
+
* @param array $posts
|
| 266 |
+
* @param WP_Query|bool $query (default: false)
|
| 267 |
+
* @return array
|
| 268 |
+
*/
|
| 269 |
+
public function the_posts( $posts, $query = false ) {
|
| 270 |
+
// Abort if there's no query
|
| 271 |
+
if ( ! $query )
|
| 272 |
+
return $posts;
|
| 273 |
+
|
| 274 |
+
// Abort if we're not filtering posts
|
| 275 |
+
if ( empty( $this->post__in ) )
|
| 276 |
+
return $posts;
|
| 277 |
+
|
| 278 |
+
// Abort if this query has already been done
|
| 279 |
+
if ( ! empty( $query->projects_query ) )
|
| 280 |
+
return $posts;
|
| 281 |
+
|
| 282 |
+
// Abort if this isn't a search query
|
| 283 |
+
if ( empty( $query->query_vars["s"] ) )
|
| 284 |
+
return $posts;
|
| 285 |
+
|
| 286 |
+
// Abort if we're not on a post type archive/project taxonomy
|
| 287 |
+
if ( ! $query->is_post_type_archive( 'project' ) && ! $query->is_tax( get_object_taxonomies( 'project' ) ) )
|
| 288 |
+
return $posts;
|
| 289 |
+
|
| 290 |
+
$filtered_posts = array();
|
| 291 |
+
$queried_post_ids = array();
|
| 292 |
+
|
| 293 |
+
foreach ( $posts as $post ) {
|
| 294 |
+
if ( in_array( $post->ID, $this->post__in ) ) {
|
| 295 |
+
$filtered_posts[] = $post;
|
| 296 |
+
$queried_post_ids[] = $post->ID;
|
| 297 |
+
}
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
$query->posts = $filtered_posts;
|
| 301 |
+
$query->post_count = count( $filtered_posts );
|
| 302 |
+
|
| 303 |
+
// Ensure filters are set
|
| 304 |
+
$this->unfiltered_project_ids = $queried_post_ids;
|
| 305 |
+
$this->filtered_project_ids = $queried_post_ids;
|
| 306 |
+
|
| 307 |
+
if ( sizeof( $this->layered_nav_post__in ) > 0 ) {
|
| 308 |
+
$this->layered_nav_project_ids = array_intersect( $this->unfiltered_project_ids, $this->layered_nav_post__in );
|
| 309 |
+
} else {
|
| 310 |
+
$this->layered_nav_project_ids = $this->unfiltered_project_ids;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
return $filtered_posts;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
/**
|
| 317 |
+
* Query the projects, applying sorting/ordering etc. This applies to the main wordpress loop
|
| 318 |
+
*
|
| 319 |
+
* @param mixed $q
|
| 320 |
+
*/
|
| 321 |
+
public function project_query( $q ) {
|
| 322 |
+
|
| 323 |
+
// Meta query
|
| 324 |
+
$meta_query = $this->get_meta_query( $q->get( 'meta_query' ) );
|
| 325 |
+
|
| 326 |
+
// Get a list of post id's which match the current filters set (in the layered nav and price filter)
|
| 327 |
+
$post__in = array_unique( apply_filters( 'loop_projects_post_in', array() ) );
|
| 328 |
+
|
| 329 |
+
// Query vars that affect posts shown
|
| 330 |
+
$q->set( 'meta_query', $meta_query );
|
| 331 |
+
$q->set( 'post__in', $post__in );
|
| 332 |
+
$q->set( 'posts_per_page', $q->get( 'posts_per_page' ) ? $q->get( 'posts_per_page' ) : apply_filters( 'loop_projects_per_page', get_option( 'posts_per_page' ) ) );
|
| 333 |
+
|
| 334 |
+
// Set a special variable
|
| 335 |
+
$q->set( 'projects_query', 'project_query' );
|
| 336 |
+
|
| 337 |
+
// Store variables
|
| 338 |
+
$this->post__in = $post__in;
|
| 339 |
+
$this->meta_query = $meta_query;
|
| 340 |
+
|
| 341 |
+
do_action( 'projects_project_query', $q, $this );
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
/**
|
| 345 |
+
* Remove the query
|
| 346 |
+
*/
|
| 347 |
+
public function remove_project_query() {
|
| 348 |
+
remove_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
/**
|
| 352 |
+
* Remove the posts_where filter
|
| 353 |
+
*/
|
| 354 |
+
public function remove_posts_where() {
|
| 355 |
+
remove_filter( 'posts_where', array( $this, 'search_post_excerpt' ) );
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
* Get an unpaginated list all project ID's (both filtered and unfiltered).
|
| 360 |
+
*/
|
| 361 |
+
public function get_projects_in_view() {
|
| 362 |
+
global $wp_the_query;
|
| 363 |
+
|
| 364 |
+
// Get main query
|
| 365 |
+
$current_wp_query = $wp_the_query->query;
|
| 366 |
+
|
| 367 |
+
// Get WP Query for current page (without 'paged')
|
| 368 |
+
unset( $current_wp_query['paged'] );
|
| 369 |
+
|
| 370 |
+
// Get all visible posts, regardless of filters
|
| 371 |
+
$unfiltered_project_ids = get_posts(
|
| 372 |
+
array_merge(
|
| 373 |
+
$current_wp_query,
|
| 374 |
+
array(
|
| 375 |
+
'post_type' => 'project',
|
| 376 |
+
'numberposts' => -1,
|
| 377 |
+
'post_status' => 'publish',
|
| 378 |
+
'meta_query' => $this->meta_query,
|
| 379 |
+
'fields' => 'ids',
|
| 380 |
+
'no_found_rows' => true,
|
| 381 |
+
'update_post_meta_cache' => false,
|
| 382 |
+
'update_post_term_cache' => false,
|
| 383 |
+
'pagename' => '',
|
| 384 |
+
'projects_query' => 'get_projects_in_view'
|
| 385 |
+
)
|
| 386 |
+
)
|
| 387 |
+
);
|
| 388 |
+
|
| 389 |
+
// Store the variable
|
| 390 |
+
$this->unfiltered_project_ids = $unfiltered_project_ids;
|
| 391 |
+
|
| 392 |
+
// Also store filtered posts ids...
|
| 393 |
+
if ( sizeof( $this->post__in ) > 0 ) {
|
| 394 |
+
$this->filtered_project_ids = array_intersect( $this->unfiltered_project_ids, $this->post__in );
|
| 395 |
+
} else {
|
| 396 |
+
$this->filtered_project_ids = $this->unfiltered_project_ids;
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
// And filtered post ids which just take layered nav into consideration
|
| 400 |
+
if ( sizeof( $this->layered_nav_post__in ) > 0 ) {
|
| 401 |
+
$this->layered_nav_project_ids = array_intersect( $this->unfiltered_project_ids, $this->layered_nav_post__in );
|
| 402 |
+
} else {
|
| 403 |
+
$this->layered_nav_project_ids = $this->unfiltered_project_ids;
|
| 404 |
+
}
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
/**
|
| 408 |
+
* Appends meta queries to an array.
|
| 409 |
+
* @access public
|
| 410 |
+
* @param array $meta_query
|
| 411 |
+
* @return array
|
| 412 |
+
*/
|
| 413 |
+
public function get_meta_query( $meta_query = array() ) {
|
| 414 |
+
if ( ! is_array( $meta_query ) )
|
| 415 |
+
$meta_query = array();
|
| 416 |
+
|
| 417 |
+
return array_filter( $meta_query );
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
} // End Class
|
projects-template.php
CHANGED
|
@@ -227,7 +227,11 @@ if ( ! function_exists( 'projects_project_archive_description' ) ) {
|
|
| 227 |
function projects_project_archive_description() {
|
| 228 |
if ( is_post_type_archive( 'project' ) && get_query_var( 'paged' ) == 0 || is_page( projects_get_page_id( 'projects' ) ) ) {
|
| 229 |
$projects_page = get_post( projects_get_page_id( 'projects' ) );
|
| 230 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
if ( $description ) {
|
| 232 |
echo '<div class="page-description">' . $description . '</div>';
|
| 233 |
}
|
|
@@ -594,4 +598,4 @@ if ( ! function_exists( 'projects_woocommerce_messages' ) ) {
|
|
| 594 |
|
| 595 |
}
|
| 596 |
}
|
| 597 |
-
}
|
| 227 |
function projects_project_archive_description() {
|
| 228 |
if ( is_post_type_archive( 'project' ) && get_query_var( 'paged' ) == 0 || is_page( projects_get_page_id( 'projects' ) ) ) {
|
| 229 |
$projects_page = get_post( projects_get_page_id( 'projects' ) );
|
| 230 |
+
$page_content = '';
|
| 231 |
+
if ( isset( $projects_page->post_content ) ) {
|
| 232 |
+
$page_content = $projects_page->post_content;
|
| 233 |
+
}
|
| 234 |
+
$description = apply_filters( 'the_content', $page_content );
|
| 235 |
if ( $description ) {
|
| 236 |
echo '<div class="page-description">' . $description . '</div>';
|
| 237 |
}
|
| 598 |
|
| 599 |
}
|
| 600 |
}
|
| 601 |
+
}
|
projects.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
* Plugin URI: http://woothemes.com/
|
| 5 |
* Description: Hi, I'm your project showcase plugin for WordPress. Show off your recent work using our shortcode, widget or template tag.
|
| 6 |
* Author: WooThemes
|
| 7 |
-
* Version: 1.
|
| 8 |
* Author URI: http://woothemes.com/
|
| 9 |
* Text Domain: projects-by-woothemes
|
| 10 |
*
|
|
@@ -46,7 +46,7 @@ final class Projects {
|
|
| 46 |
/**
|
| 47 |
* @var string
|
| 48 |
*/
|
| 49 |
-
public $version = '1.
|
| 50 |
|
| 51 |
/**
|
| 52 |
* Constructor function.
|
|
@@ -61,7 +61,7 @@ final class Projects {
|
|
| 61 |
$this->assets_dir = trailingslashit( $this->dir ) . 'assets';
|
| 62 |
$this->assets_url = esc_url( trailingslashit( plugins_url( '/assets/', $file ) ) );
|
| 63 |
$this->token = 'projects';
|
| 64 |
-
$this->post_type = 'project';
|
| 65 |
|
| 66 |
// Upgrade data
|
| 67 |
$this->upgrade_data( true );
|
|
@@ -159,7 +159,7 @@ final class Projects {
|
|
| 159 |
|
| 160 |
);
|
| 161 |
$args = array(
|
| 162 |
-
'labels' => $labels,
|
| 163 |
'public' => true,
|
| 164 |
'publicly_queryable' => true,
|
| 165 |
'show_ui' => true,
|
| 4 |
* Plugin URI: http://woothemes.com/
|
| 5 |
* Description: Hi, I'm your project showcase plugin for WordPress. Show off your recent work using our shortcode, widget or template tag.
|
| 6 |
* Author: WooThemes
|
| 7 |
+
* Version: 1.5.0
|
| 8 |
* Author URI: http://woothemes.com/
|
| 9 |
* Text Domain: projects-by-woothemes
|
| 10 |
*
|
| 46 |
/**
|
| 47 |
* @var string
|
| 48 |
*/
|
| 49 |
+
public $version = '1.5.0';
|
| 50 |
|
| 51 |
/**
|
| 52 |
* Constructor function.
|
| 61 |
$this->assets_dir = trailingslashit( $this->dir ) . 'assets';
|
| 62 |
$this->assets_url = esc_url( trailingslashit( plugins_url( '/assets/', $file ) ) );
|
| 63 |
$this->token = 'projects';
|
| 64 |
+
$this->post_type = apply_filters( 'projects_post_type_designation', 'project' );
|
| 65 |
|
| 66 |
// Upgrade data
|
| 67 |
$this->upgrade_data( true );
|
| 159 |
|
| 160 |
);
|
| 161 |
$args = array(
|
| 162 |
+
'labels' => apply_filters( 'projects_post_type_labels', $labels, $labels ),
|
| 163 |
'public' => true,
|
| 164 |
'publicly_queryable' => true,
|
| 165 |
'show_ui' => true,
|
readme.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
=== Projects by WooThemes ===
|
| 2 |
-
Contributors: woothemes, mattyza, jameskoster, tiagonoronha
|
| 3 |
Donate link: http://woothemes.com/
|
| 4 |
Tags: portfolio, projects, project, showcase, artwork, work, creative, photography, art, images, woocommerce
|
| 5 |
-
Requires at least:
|
| 6 |
-
Tested up to: 4.
|
| 7 |
-
Stable tag: 1.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -103,6 +103,9 @@ You sure can! Read about how in the [documentation](http://docs.woothemes.com/do
|
|
| 103 |
|
| 104 |
== Upgrade Notice ==
|
| 105 |
|
|
|
|
|
|
|
|
|
|
| 106 |
= 1.4.2 =
|
| 107 |
* Removes deprecated constructor call for WP_Widget
|
| 108 |
|
|
@@ -121,6 +124,10 @@ You sure can! Read about how in the [documentation](http://docs.woothemes.com/do
|
|
| 121 |
|
| 122 |
== Changelog ==
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
= 1.4.2 =
|
| 125 |
* 2015.07.07
|
| 126 |
* Tweak - Allow attribute for include_children inside taxonomy query.
|
| 1 |
=== Projects by WooThemes ===
|
| 2 |
+
Contributors: woothemes, mattyza, jameskoster, tiagonoronha, jeffikus
|
| 3 |
Donate link: http://woothemes.com/
|
| 4 |
Tags: portfolio, projects, project, showcase, artwork, work, creative, photography, art, images, woocommerce
|
| 5 |
+
Requires at least: 4.0
|
| 6 |
+
Tested up to: 4.3.1
|
| 7 |
+
Stable tag: 1.5.0
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 103 |
|
| 104 |
== Upgrade Notice ==
|
| 105 |
|
| 106 |
+
= 1.5.0 =
|
| 107 |
+
* Fixes projects page not loading - please resave permalinks after updating!
|
| 108 |
+
|
| 109 |
= 1.4.2 =
|
| 110 |
* Removes deprecated constructor call for WP_Widget
|
| 111 |
|
| 124 |
|
| 125 |
== Changelog ==
|
| 126 |
|
| 127 |
+
= 1.5.0 =
|
| 128 |
+
* 2015.12.07
|
| 129 |
+
* New/Fix - Adds query class to modify the query to fix the Project page not loading.
|
| 130 |
+
|
| 131 |
= 1.4.2 =
|
| 132 |
* 2015.07.07
|
| 133 |
* Tweak - Allow attribute for include_children inside taxonomy query.
|
