Quick commit before work today, still incomplete
This commit is contained in:
@ -72,12 +72,49 @@ class CWV3 {
|
|||||||
if ( is_attachment() && isset( $post->post_parent ) ) {
|
if ( is_attachment() && isset( $post->post_parent ) ) {
|
||||||
// Special consideration needs to be taken to check if the post parent is in-fact
|
// Special consideration needs to be taken to check if the post parent is in-fact
|
||||||
// gated in any way, if so, return its ID here.
|
// gated in any way, if so, return its ID here.
|
||||||
$is_gated = $this->check_post( $post->post_parent );
|
$is_gated = $this->is_gated( $post->post_parent );
|
||||||
if ( true === $is_gated ){
|
if ( true === $is_gated ){
|
||||||
return $post->post_parent;
|
return $post->post_parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( is_single() && isset( $post->ID ) ){
|
||||||
|
$is_gated = $this->is_gated( $post->ID );
|
||||||
|
if ( true == $is_gated ){
|
||||||
|
return $post->ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Post
|
||||||
|
* Checks a post ID to see if it's supposed to be
|
||||||
|
* gated in any way, either by metabox, or category from the
|
||||||
|
* regular category taxonomy.
|
||||||
|
*
|
||||||
|
* @param int $post_id Post ID
|
||||||
|
* @return bool TRUE | FALSE
|
||||||
|
*/
|
||||||
|
public function is_gated( $post_id ){
|
||||||
|
|
||||||
|
$meta = get_post_meta( $post_id, 'cwv3_auth', true );
|
||||||
|
|
||||||
|
if ( ! empty( $meta ) ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// The post itself was not gated, check categories.
|
||||||
|
$category_array = get_option( 'cwv3_cat_list', array() );
|
||||||
|
if ( ! empty( $category_array ) ){
|
||||||
|
// We have categories to check, so let us do so.
|
||||||
|
$current_categories = get_the_category( $post_id );
|
||||||
|
if ( $this->in_cat( $category_array, $current_categories ) ){
|
||||||
|
// @TODO Continue here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*$type = get_post_type( $id );
|
/*$type = get_post_type( $id );
|
||||||
if ( 'post' == $type ) {
|
if ( 'post' == $type ) {
|
||||||
$catData = get_option( 'cwv3_cat_list' );
|
$catData = get_option( 'cwv3_cat_list' );
|
||||||
@ -99,22 +136,6 @@ class CWV3 {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check Post
|
|
||||||
* Checks a post ID to see if it's supposed to be
|
|
||||||
* gated in any way, either by metabox, or category from the
|
|
||||||
* regular category taxonomy.
|
|
||||||
*
|
|
||||||
* @param int $post_id Post ID
|
|
||||||
* @return bool TRUE | FALSE
|
|
||||||
*/
|
|
||||||
public function check_post( $post_id ){
|
|
||||||
|
|
||||||
$meta = get_post_meta( $post_id, $key, true );
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function set_cookie( $id, $action ) {
|
public function set_cookie( $id, $action ) {
|
||||||
|
|
||||||
$time = get_option( 'cwv3_death' );
|
$time = get_option( 'cwv3_death' );
|
||||||
|
Reference in New Issue
Block a user