Skip to content

Commit

Permalink
Move localized params to var for dumping during dev | update if..else
Browse files Browse the repository at this point in the history
logic to include new cat method | fixes #18
  • Loading branch information
JayWood committed Jan 12, 2015
1 parent ad62eff commit 335ed32
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions class/main.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,24 @@ public function get_cookie_name(){
return 'misc';
}

// Don't need people looking at attachments that belong to a
// protected post.
if ( is_attachment() && isset( $post->post_parent ) ) {
// 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.
if ( $this->is_gated( $post->post_parent ) ){
// gated in any way.
$cat_gated = $this->is_cat_gated( $post->post_parent );
if ( ! empty( $cat_gated ) ){
// Return the category cookie name like _cat_###
return '_cat_' . $cat_gated;
} else if ( $this->is_gated( $post->post_parent ) ){
return $post->post_parent;
}
}

if ( is_singular() && isset( $post->ID ) ){
if ( $this->is_gated( $post->ID ) ){
$cat_gated = $this->is_cat_gated( $post->ID );
if ( ! empty( $cat_gated ) ){
// Return the category cookie name like _cat_###
return '_cat_' . $cat_gated;
} else if ( $this->is_gated( $post->ID ) ){
return $post->ID;
}
}
Expand Down Expand Up @@ -104,9 +110,9 @@ public function in_cat( $cat_settings, $post_categories ) {
$cat_settings = array(); // Empty
}

foreach ( $post_categories as $cat ) {
if ( in_array( $cat->term_id, $post_categories ) ) {
return $cat->term_id;
foreach ( $post_categories as $post_category ) {
if ( in_array( $post_category->term_id, $cat_settings ) ) {
return $post_category->term_id;
} else {
continue;
}
Expand Down Expand Up @@ -143,17 +149,17 @@ public function load_dependancies() {
wp_enqueue_script( 'cwv3_js' );

$cookie_death = get_option( 'cwv3_death', 1 );

wp_localize_script( 'cwv3_js', 'cwv3_params', array(
$localized_data = array(
'opacity' => get_option( 'cwv3_bg_opacity', 0.85 ),
'cookie_path' => SITECOOKIEPATH,
'cookie_name' => $this->get_cookie_name(),
'cookie_time' => intval( $cookie_death ) > 365 ? 365 : intval( $cookie_death ), // Max at one year if it's over 365 days.
'denial_enabled' => get_option( 'cwv3_denial', 'enabled' ),
'denial_method' => get_option( 'cwv3_method', 'redirect' ),
'redirect_url' => esc_js( get_option( 'cwv3_exit_link', '#' ) ),
);

) );
wp_localize_script( 'cwv3_js', 'cwv3_params', $localized_data );
}

/**
Expand Down

0 comments on commit 335ed32

Please sign in to comment.