small update to greatness
This commit is contained in:
@ -31,22 +31,7 @@ class CWV3 {
|
||||
}
|
||||
|
||||
public function override_css() {
|
||||
|
||||
$img = get_option( 'cwv3_bg_image', '' );
|
||||
$color = get_option( 'cwv3_bg_color' );
|
||||
?><style type="text/css"><?php
|
||||
$custom_css = get_option( 'cwv3_css', '' );
|
||||
|
||||
if ( ! empty( $custom_css ) ){
|
||||
echo $custom_css;
|
||||
}
|
||||
|
||||
if ( ! empty( $img ) ) {
|
||||
?>#cboxOverlay{background:url(<?php echo $img; ?>) no-repeat top center; background-color:<?php echo $color['color']; ?>;}<?php
|
||||
}else {
|
||||
?> #cboxOverlay{background-image:url(<?php echo $img; ?>) no-repeat top center; background-color:<?php echo $color['color']; ?>;} <?php
|
||||
}
|
||||
?></style><?php
|
||||
cwv3_the_css();
|
||||
}
|
||||
|
||||
public function render_lazy_mans_css() {
|
||||
@ -222,57 +207,7 @@ class CWV3 {
|
||||
}
|
||||
|
||||
public function check_data() {
|
||||
global $post;
|
||||
|
||||
if ( is_feed() ) {
|
||||
//Don't want to hender the feed, just in case.
|
||||
return true;
|
||||
}
|
||||
|
||||
$cData = array(
|
||||
// check isset before access (edit by @jgraup)
|
||||
'pages' => ! isset( $_COOKIE['cwv3_pages'] ) ? '' : json_decode( stripslashes( @$_COOKIE['cwv3_pages'] ), true ),
|
||||
'posts' => ! isset( $_COOKIE['cwv3_posts'] ) ? '' : json_decode( stripslashes( @$_COOKIE['cwv3_posts'] ), true ),
|
||||
'categories' => ! isset( $_COOKIE['cwv3_cats'] ) ? '' : json_decode( stripslashes( @$_COOKIE['cwv3_cats'] ), true )
|
||||
);
|
||||
|
||||
$sw = get_option( 'cwv3_sitewide' );
|
||||
$hm = get_option( 'cwv3_homepage' );
|
||||
$mi = get_option( 'cwv3_misc' );
|
||||
|
||||
if ( ! empty( $sw ) ) {
|
||||
return ! empty( $cData['pages']['sitewide'] ) ? $cData['pages']['sitewide'] : false;
|
||||
}
|
||||
|
||||
if ( is_front_page() && ! empty( $hm ) ) {
|
||||
return ! empty( $cData['pages']['home'] ) ? $cData['pages']['home'] : false;
|
||||
}
|
||||
|
||||
if ( ( is_archive() || is_search() ) && ! empty( $mi ) ) {
|
||||
// Protect misc pages aswell
|
||||
return ! empty( $cData['pages']['other'] ) ? $cData['pages']['other'] : false;
|
||||
}
|
||||
|
||||
if ( is_page() && 'yes' == get_post_meta( $post->ID, 'cwv3_auth', true ) ) {
|
||||
$c = $cData['pages'][ $post->ID ];
|
||||
return ! empty( $c ) ? $c : false;
|
||||
}
|
||||
|
||||
$id = ( is_attachment() ? $post->post_parent : $post->ID );
|
||||
// First see if categories are setup in the admin side.
|
||||
$catData = get_option( 'cwv3_cat_list' );
|
||||
$curCat = get_the_category( $id );
|
||||
if ( 'post' == get_post_type( $id ) && $this->in_cat( $catData, $curCat ) ) {
|
||||
// If the current category is selected in the admin page, that means the administrator wishes to protect it.
|
||||
// respect the admin's wishes and do it.
|
||||
return ! empty( $cData['categories'][ $post->ID ] ) ? $cData['categories'][ $id ] : false;
|
||||
}
|
||||
// Since that's not the case, we need to check post_meta data and see if this post is protected.
|
||||
if ( 'yes' == get_post_meta( $post->ID, 'cwv3_auth', true ) && ! is_front_page() ) {
|
||||
return ! empty( $cData['posts'][ $post->ID ] ) ? $cData['posts'][ $id ] : false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return cwv3_auth_reply();
|
||||
}
|
||||
|
||||
public function in_cat( $catIDs, $catArray ) {
|
||||
@ -292,36 +227,8 @@ class CWV3 {
|
||||
|
||||
public function render_dialog() {
|
||||
|
||||
$d = get_option( 'cwv3_denial' );
|
||||
if ( 3 == $this->check_data() && 'enabled' == $d[0] ) {
|
||||
$dtype = true;
|
||||
}else {
|
||||
$dtype = false;
|
||||
}
|
||||
$etxt = get_option( 'cwv3_enter_txt', 'Enter' );
|
||||
$extxt = get_option( 'cwv3_exit_txt', 'Exit' );
|
||||
cwv3_the_dialog();
|
||||
|
||||
$cwv3_title = ( true == $dtype ) ? get_option( 'cwv3_den_title' ) : get_option( 'cwv3_d_title' );
|
||||
$cwv3_content = ( true == $dtype ) ? get_option( 'cwv3_den_msg' ) : get_option( 'cwv3_d_msg' );
|
||||
|
||||
$exit_url = get_option( 'cwv3_exit_link', '#' );
|
||||
$enter_url = get_option( 'cwv3_enter_link', '#' );
|
||||
?>
|
||||
<!-- CWV3 Dialog -->
|
||||
<div style="display: none">
|
||||
<div id="cwv3_auth">
|
||||
<div id="cwv3_title"><?php echo esc_attr( $title ); ?></div>
|
||||
<div id="cwv3_content"><?php echo wp_kses_post( $cwv3_content ); ?></div>
|
||||
<div id="cwv3_btns">
|
||||
<?php if ( true !== $dtype ): ?>
|
||||
<div id="cwv3_enter"><a href="<?php echo esc_url( $enter_url ); ?>" id="cw_enter_link"><?php echo esc_attr( $etxt ); ?></a></div>
|
||||
<?php endif; ?>
|
||||
<div id="cwv3_exit"><a href="<?php echo esc_url( $exit_url ); ?>" id="cw_exit_link"><?php echo esc_attr( $extxt ); ?></a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END CWV3 Dialog -->
|
||||
<?php
|
||||
}
|
||||
|
||||
public function render_metabox( $post ) {
|
||||
|
@ -54,4 +54,9 @@
|
||||
background-color: #F00;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=cwv3.css.map */
|
||||
.cwv3_dialog.js .auth {
|
||||
display: none;
|
||||
}
|
||||
.cwv3_dialog.js .denied {
|
||||
display: none;
|
||||
}
|
||||
|
2
css/cwv3.min.css
vendored
2
css/cwv3.min.css
vendored
@ -1 +1 @@
|
||||
.cwv3_box{background:0 0}#cboxContent,#cboxLoadedContent,#cboxLoadingOverlay{background-color:#FFF!important}#cwv3_auth{border:3px solid #ccc;background:#FFF}#cwv3_auth div{padding:.25em}#cwv3_title{color:#FFF;font-weight:700;text-align:center;background:red}#cwv3_btns{overflow:hidden}#cwv3_btns div a{display:block;width:100%;text-align:center;color:#FFF;font-weight:700;text-decoration:none}#cwv3_enter{float:left;width:40%}#cwv3_enter a{background-color:#0C3}#cwv3_exit{float:right;width:40%}#cwv3_exit a{background-color:red}
|
||||
.cwv3_box{background:0 0}#cboxContent,#cboxLoadedContent,#cboxLoadingOverlay{background-color:#FFF!important}#cwv3_auth{border:3px solid #ccc;background:#FFF}#cwv3_auth div{padding:.25em}#cwv3_title{color:#FFF;font-weight:700;text-align:center;background:red}#cwv3_btns{overflow:hidden}#cwv3_btns div a{display:block;width:100%;text-align:center;color:#FFF;font-weight:700;text-decoration:none}#cwv3_enter{float:left;width:40%}#cwv3_enter a{background-color:#0C3}#cwv3_exit{float:right;width:40%}#cwv3_exit a{background-color:red}.cwv3_dialog.js .auth,.cwv3_dialog.js .denied{display:none}
|
@ -54,3 +54,19 @@
|
||||
#cwv3_exit a {
|
||||
background-color: #F00;
|
||||
}
|
||||
|
||||
.cwv3_dialog{
|
||||
|
||||
&.js{
|
||||
|
||||
.auth{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.denied{
|
||||
display: none;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
44
inc/api.php
44
inc/api.php
@ -40,3 +40,47 @@ function cwv3_get_css(){
|
||||
return apply_filters( 'cwv3_css', ob_get_clean() );
|
||||
}
|
||||
|
||||
function cwv3_js_dialog(){
|
||||
|
||||
}
|
||||
|
||||
function cwv3_get_js_dialog(){
|
||||
|
||||
$exit_text = get_option( 'cwv3_exit_txt', __( 'Exit', 'cwv3' ) );
|
||||
$enter_text = get_option( 'cwv3_enter_txt', __( 'Enter', 'cwv3' ) );
|
||||
|
||||
$cwv3_denial_title = get_option( 'cwv3_den_title', __( 'Access Denied', 'cwv3' ) );
|
||||
$cwv3_denial_message = get_option( 'cwv3_den_msg', __( 'You have been denied access to this content. If you feel this is in error, please contact a site administrator.', 'cwv3' ) );
|
||||
|
||||
$cwv3_title = get_option( 'cwv3_den_title', __( 'Access Denied', 'cwv3' ) );
|
||||
$cwv3_message = get_option( 'cwv3_den_msg', __( 'You have been denied access to this content. If you feel this is in error, please contact a site administrator.', 'cwv3' ) );
|
||||
|
||||
$exit_url = get_option( 'cwv3_exit_link', '#' );
|
||||
$enter_url = get_option( 'cwv3_enter_link', '#' );
|
||||
?>
|
||||
<div id="cwv3_dialog" class="cwv3_dialog js">
|
||||
<div class="cwv3 auth">
|
||||
<div class="cwv3_title"><?php echo esc_attr( $cwv3_den_title ); ?></div>
|
||||
<div class="cwv3_content"><?php echo wp_kses_post( $cwv3_den_msg ); ?></div>
|
||||
<div class="cwv3_btns">
|
||||
<div class="cwv3_enter">
|
||||
<a href="<?php echo esc_url( $enter_url ); ?>"><?php echo esc_attr( $enter_text ); ) ?></a>
|
||||
</div>
|
||||
<div class="cwv3_exit">
|
||||
<a href="<?php echo esc_url( $exit_url ); ?>"><?php echo esc_attr( $exit_url ); ) ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cwv3 denied">
|
||||
<div class="cwv3_title"><?php echo esc_attr( $cwv3_title ); ?></div>
|
||||
<div class="cwv3_content"><?php echo wp_kses_post( $cwv3_message ); ?></div>
|
||||
<div class="cwv3_btns">
|
||||
<div class="cwv3_exit">
|
||||
<a href="<?php echo esc_url( $exit_url ); ?>"><?php echo esc_attr( $exit_url ); ) ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
21
js/cwv3.js
21
js/cwv3.js
@ -1,4 +1,23 @@
|
||||
/* global cwv3_params */
|
||||
|
||||
window.cwv3 = ( function( window, document, $ ){
|
||||
|
||||
var app = {};
|
||||
|
||||
app.cache = function(){
|
||||
|
||||
};
|
||||
|
||||
app.init = function(){
|
||||
|
||||
};
|
||||
|
||||
$( document ).ready( app.init );
|
||||
|
||||
return app;
|
||||
|
||||
})( window, document, jQuery );
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
var enter = $('#cw_enter_link');
|
||||
var exit = $('#cw_exit_link');
|
||||
@ -25,7 +44,7 @@ jQuery(document).ready(function($) {
|
||||
if( typeof(e) !== "undefined" ){
|
||||
e.preventDefault();
|
||||
}
|
||||
//console.log(e);
|
||||
|
||||
$.post(cwv3_params.admin_url, {action: cwv3_params.action, nonce: cwv3_params.nonce, id: cwv3_params.id, method: 'enter'}, function(){
|
||||
if(cwv3_params.enter === "#"){
|
||||
$.colorbox.close();
|
||||
|
2
js/cwv3.min.js
vendored
2
js/cwv3.min.js
vendored
@ -1 +1 @@
|
||||
jQuery(document).ready(function($){var enter=$("#cw_enter_link"),exit=$("#cw_exit_link");"1"===cwv3_params.sd&&($.colorbox({scrolling:!1,overlayClose:!1,escKey:!1,inline:!0,href:"#cwv3_auth",maxWidth:"80%",loop:!1,onLoad:function(){$("#cboxClose").remove()},className:"cwv3_box",opacity:cwv3_params.opacity}),enter.click(function(e){"undefined"!=typeof e&&e.preventDefault(),$.post(cwv3_params.admin_url,{action:cwv3_params.action,nonce:cwv3_params.nonce,id:cwv3_params.id,method:"enter"},function(){"#"===cwv3_params.enter?$.colorbox.close():window.location=cwv3_params.enter})}),exit.click(function(e){"undefined"!=typeof e&&e.preventDefault(),$.post(cwv3_params.admin_url,{action:cwv3_params.action,nonce:cwv3_params.nonce,id:cwv3_params.id,method:"exit"},function(){window.location=cwv3_params.exit})}))});
|
||||
window.cwv3=function(window,document,$){var app={};return app.cache=function(){},app.init=function(){},$(document).ready(app.init),app}(window,document,jQuery),jQuery(document).ready(function($){var enter=$("#cw_enter_link"),exit=$("#cw_exit_link");"1"===cwv3_params.sd&&($.colorbox({scrolling:!1,overlayClose:!1,escKey:!1,inline:!0,href:"#cwv3_auth",maxWidth:"80%",loop:!1,onLoad:function(){$("#cboxClose").remove()},className:"cwv3_box",opacity:cwv3_params.opacity}),enter.click(function(e){"undefined"!=typeof e&&e.preventDefault(),$.post(cwv3_params.admin_url,{action:cwv3_params.action,nonce:cwv3_params.nonce,id:cwv3_params.id,method:"enter"},function(){"#"===cwv3_params.enter?$.colorbox.close():window.location=cwv3_params.enter})}),exit.click(function(e){"undefined"!=typeof e&&e.preventDefault(),$.post(cwv3_params.admin_url,{action:cwv3_params.action,nonce:cwv3_params.nonce,id:cwv3_params.id,method:"exit"},function(){window.location=cwv3_params.exit})}))});
|
Reference in New Issue
Block a user