Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,146 @@
<?php
/**
* The file contains a class to configure the metabox Advanced Options.
*
* Created via the Factory Metaboxes.
*
* @author Paul Kashtanoff <paul@byonepress.com>
* @copyright (c) 2013, OnePress Ltd
*
* @package core
* @since 1.0.0
*/
/**
* The class to configure the metabox Advanced Options.
*
* @since 1.0.0
*/
class OPanda_AdvancedOptionsMetaBox extends FactoryMetaboxes321_FormMetabox
{
/**
* A visible title of the metabox.
*
* Inherited from the class FactoryMetabox.
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
*
* @since 1.0.0
* @var string
*/
public $title;
/**
* A prefix that will be used for names of input fields in the form.
*
* Inherited from the class FactoryFormMetabox.
*
* @since 1.0.0
* @var string
*/
public $scope = 'opanda';
/**
* The priority within the context where the boxes should show ('high', 'core', 'default' or 'low').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $priority = 'core';
/**
* The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $context = 'side';
public function __construct( $plugin ) {
parent::__construct( $plugin );
$this->title = __('Advanced Options', 'bizpanda');
}
public $cssClass = 'factory-bootstrap-331';
/**
* Configures a form that will be inside the metabox.
*
* @see FactoryMetaboxes321_FormMetabox
* @since 1.0.0
*
* @param FactoryForms328_Form $form A form object to configure.
* @return void
*/
public function form( $form ) {
$options = array(
array(
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'close',
'title' => __('Close Icon', 'bizpanda'),
'hint' => __('Shows the Close Icon at the corner.', 'bizpanda'),
'icon' => OPANDA_BIZPANDA_URL . '/assets/admin/img/close-icon.png',
'default' => false
),
array(
'type' => 'textbox',
'name' => 'timer',
'title' => __('Timer Interval', 'bizpanda'),
'hint' => __('Sets a countdown interval for the locker.', 'bizpanda'),
'icon' => OPANDA_BIZPANDA_URL . '/assets/admin/img/timer-icon.png',
'default' => false
),
array(
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'ajax',
'title' => __('AJAX', 'bizpanda'),
'hint' => __('If On, locked content will be cut from a page source code.', 'bizpanda'),
'icon' => OPANDA_BIZPANDA_URL . '/assets/admin/img/ajax-icon.png',
'default' => false
),
array(
'type' => 'html',
'html' => '<div id="opanda-ajax-disabled" class="alert alert-warning">The option AJAX is not applied when the "transparence" or "blurring" overlap modes selected.</div>'
),
array(
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'highlight',
'title' => __('Highlight', 'bizpanda'),
'hint' => __('Defines whether the locker must use the Highlight effect.', 'bizpanda'),
'icon' => OPANDA_BIZPANDA_URL . '/assets/admin/img/highlight-icon.png',
'default' => true
)
);
if ( OPanda_Items::isCurrentFree() ) {
$options[] = array(
'type' => 'html',
'html' => '<div style="display: none;" class="factory-fontawesome-320 opanda-overlay-note opanda-premium-note">' . __( '<i class="fa fa-star-o"></i> Go Premium <i class="fa fa-star-o"></i><br />To Unlock These Features <a href="#" class="opnada-button">Learn More</a>', 'bizpanda' ) . '</div>'
);
}
$options = apply_filters('opanda_advanced_options', $options);
$form->add($options);
}
}
global $bizpanda;
FactoryMetaboxes321::register('OPanda_AdvancedOptionsMetaBox', $bizpanda);

View File

@@ -0,0 +1,260 @@
<?php
/**
* The file contains a class to configure the metabox Basic Options.
*
* Created via the Factory Metaboxes.
*
* @author Paul Kashtanoff <paul@byonepress.com>
* @copyright (c) 2013, OnePress Ltd
*
* @package core
* @since 1.0.0
*/
/**
* The class to configure the metabox Basic Options.
*
* @since 1.0.0
*/
class OPanda_BasicOptionsMetaBox extends FactoryMetaboxes321_FormMetabox
{
/**
* A visible title of the metabox.
*
* Inherited from the class FactoryMetabox.
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
*
* @since 1.0.0
* @var string
*/
public $title;
/**
* A prefix that will be used for names of input fields in the form.
* Inherited from the class FactoryFormMetabox.
*
* @since 1.0.0
* @var string
*/
public $scope = 'opanda';
/**
* The priority within the context where the boxes should show ('high', 'core', 'default' or 'low').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $priority = 'core';
public $cssClass = 'factory-bootstrap-331 factory-fontawesome-320';
public function __construct( $plugin ) {
parent::__construct( $plugin );
$this->title = __('Basic Options', 'bizpanda');
}
/**
* Configures a form that will be inside the metabox.
*
* @see FactoryMetaboxes321_FormMetabox
* @since 1.0.0
*
* @param FactoryForms328_Form $form A form object to configure.
* @return void
*/
public function form( $form ) {
$itemType = OPanda_Items::getCurrentItem();
$form->add(
array(
'type' => 'hidden',
'name' => 'item',
'default' => isset( $_GET['opanda_item'] ) ? $_GET['opanda_item'] : null
)
);
$defaultHeader = __('This content is locked!', 'bizpanda');
$defaultMessage = __('Please support us, use one of the buttons below to unlock the content.', 'bizpanda');
switch ($itemType['name']) {
case 'email-locker':
$defaultHeader = __('This Content Is Only For Subscribers', 'bizpanda');
$defaultMessage = __('Please subscribe to unlock this content. Just enter your email below.', 'bizpanda');
break;
case 'connect-locker':
$defaultHeader = __('Sing In To Unlock This Content', 'bizpanda');
$defaultMessage = __('Please sign in. It\'s free. Just click one of the buttons below to get instant access.', 'bizpanda');
break;
}
$textOptions = array(
array(
'type' => 'textbox',
'name' => 'header',
'title' => __('Locker Header', 'bizpanda'),
'hint' => __('Type a header which attracts attention or calls to action. You can leave this field empty.', 'bizpanda'),
'default' => $defaultHeader
),
array(
'type' => 'wp-editor',
'name' => 'message',
'title' => __('Locker Message', 'bizpanda'),
'hint' => __('Type a message which will appear under the header.', 'bizpanda').'<br /><br />'.
__('Shortcodes: [post_title], [post_url].', 'bizpanda'),
'default' => $defaultMessage,
'tinymce' => array(
'setup' => 'function(ed){ window.bizpanda.lockerEditor.bindWpEditorChange( ed ); }',
'height' => 100
),
'layout' => array(
'hint-position' => 'left'
)
),
);
$textOptions = apply_filters('opanda_text_options', $textOptions );
$form->add($textOptions);
if ( 'email-locker' === $itemType['name'] ) {
$form->add( array(
'type' => 'columns',
'items' => array(
array(
'type' => 'textbox',
'name' => 'button_text',
'title' => __('Buttton Text', 'bizpanda'),
'hint' => __('The text on the button. Call to action!'),
'default' => __('subscribe to unlock', 'bizpanda'),
'column' => 1
),
array(
'type' => 'textbox',
'name' => 'after_button',
'title' => __('After Buttton', 'bizpanda'),
'hint' => __('The text below the button. Guarantee something.'),
'default' => __('Your email address is 100% safe from spam!', 'bizpanda'),
'column' => 2
)
)
));
}
$form->add( array(
'type' => 'html',
'html' => array( $this, 'showOtherFrontendTextNote' )
));
$form->add( array(
'type' => 'separator'
));
require_once OPANDA_BIZPANDA_DIR . '/includes/themes.php';
$form->add(array(
array(
'type' => 'dropdown',
'hasHints' => true,
'name' => 'style',
'data' => OPanda_ThemeManager::getThemes( OPanda_Items::getCurrentItemName(), 'dropdown'),
'title' => __('Theme', 'bizpanda'),
'hint' => __('Select the most suitable theme.', 'bizpanda'),
'default' => OPanda_Items::isCurrentPremium() ? 'flat' : 'secrets'
)
));
if ( OPanda_Items::isCurrentPremium() ) {
$form->add(array(
array(
'type' => 'dropdown',
'way' => 'buttons',
'name' => 'overlap',
'data' => array(
array('full', '<i class="fa fa-lock"></i>'.__('Full (classic)', 'bizpanda')),
array('transparence', '<i class="fa fa-adjust"></i>'.__('Transparency', 'bizpanda') ),
array('blurring', '<i class="fa fa-bullseye"></i>'.__('Blurring', 'bizpanda') )
),
'title' => __('Overlap Mode', 'bizpanda'),
'hint' => __('Choose the way how your locker should lock the content.', 'bizpanda'),
'default' => 'full'
)
));
} else {
$form->add(array(
array(
'type' => 'dropdown',
'way' => 'buttons',
'name' => 'overlap',
'data' => array(
array('full', '<i class="fa fa-lock"></i>Full (classic)'),
array('transparence', '<i class="fa fa-adjust"></i>Transparency' ),
array('blurring', '<i class="fa fa-bullseye"></i>Blurring', sprintf( __( 'This option is available only in the <a href="%s" target="_blank">premium version</a> of the plugin (the transparency mode will be used in the free version)', 'bizpanda' ), opanda_get_premium_url( null, 'blurring' ) ) )
),
'title' => __('Overlap Mode', 'bizpanda'),
'hint' => __('Choose the way how your locker should lock the content.', 'bizpanda'),
'default' => 'full'
)
));
}
$form->add(array(
array(
'type' => 'dropdown',
'name' => 'overlap_position',
'data' => array(
array('top', __( 'Top Position', 'bizpanda' ) ),
array('middle', __( 'Middle Position', 'bizpanda' ) ),
array('scroll', __( 'Scrolling (N/A in Preview)', 'bizpanda' ) )
),
'title' => '',
'hint' => '',
'default' => 'middle'
)
));
}
/**
* Replaces the 'blurring' overlap with 'transparence' in the free version.
*
* @since 1.0.0
* @param type $postId
*/
public function onSavingForm( $postId ) {
if ( !OPanda_Items::isCurrentFree() ) return;
$overlap = isset ( $_POST['opanda_overlap'] ) ? $_POST['opanda_overlap'] : null;
if ( $overlap == 'blurring' ) $_POST['opanda_overlap'] = 'transparence';
}
public function showOtherFrontendTextNote() {
?>
<div class="form-group opanda-edit-common-text">
<label class="col-sm-2 control-label"></label>
<div class="control-group controls col-sm-10">
<?php printf( __('<a href="%s" target="_blank">Click here</a> to edit the front-end text shared for all lockers.', 'bizpanda'), opanda_get_settings_url('text') ) ?>
</div>
</div>
<?php
}
}
global $bizpanda;
FactoryMetaboxes321::register('OPanda_BasicOptionsMetaBox', $bizpanda);

View File

@@ -0,0 +1,516 @@
<?php
/**
* The file contains a class to configure the metabox Bulk Locking.
*
* Created via the Factory Metaboxes.
*
* @author Paul Kashtanoff <paul@byonepress.com>
* @copyright (c) 2013, OnePress Ltd
*
* @package core
* @since 1.0.0
*/
/**
* The class to show info on how the plugin support is provided.
*
* @since 1.0.0
*/
class OPanda_BulkLockingMetaBox extends FactoryMetaboxes321_Metabox
{
/**
* A visible title of the metabox.
*
* Inherited from the class FactoryMetabox.
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
*
* @since 1.0.0
* @var string
*/
public $title;
/**
* The priority within the context where the boxes should show ('high', 'core', 'default' or 'low').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $priority = 'core';
/**
* The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $context = 'side';
public function __construct( $plugin ) {
parent::__construct( $plugin );
$this->title = __('Batch Locking', 'bizpanda');
}
public function configure( $scripts, $styles ){
$scripts->add( OPANDA_BIZPANDA_URL . '/assets/admin/js/metaboxes/bulk-lock.010000.js');
}
/**
* Renders content of the metabox.
*
* @see FactoryMetaboxes321_Metabox
* @since 1.0.0
*
* @return void
*/
public function html()
{
global $post;
$options = get_post_meta($post->ID, 'opanda_bulk_locking', true);
// current bulk locker for the "skip & lock" and "more tag" modes
$bulkLockerId = intval( get_option('onp_sl_bulk_locker', 0) );
$bulkLocker = null;
if ( $bulkLockerId !== 0 && $bulkLockerId != $post->ID ) {
$bulkLocker = get_post($bulkLockerId);
if ( $bulkLocker && empty( $bulkLocker->post_title ) ) $bulkLocker->post_title = __('No title', 'bizpanda');
}
// gets values for the form
$setupStateClass = empty( $options ) ? 'onp-sl-empty-state' : 'onp-sl-has-options-state';
$wayStateClass = '';
if ( !empty($options) && isset( $options['way'] ) ) {
if ( $options['way'] == 'skip-lock' ) $wayStateClass = 'onp-sl-skip-lock-state';
elseif ( $options['way'] == 'more-tag' ) $wayStateClass = 'onp-sl-more-tag-state';
elseif ( $options['way'] == 'css-selector' ) $wayStateClass = 'onp-sl-css-selector-state';
}
$skipAndLockStateClass = '';
if ( !empty($options) && $options['way'] == 'skip-lock' ) {
if ( $options['skip_number'] == 0 ) $skipAndLockStateClass = 'onp-sl-skip-lock-0-state';
elseif ( $options['skip_number'] == 1 ) $skipAndLockStateClass = 'onp-sl-skip-lock-1-state';
elseif ( $options['skip_number'] > 1 ) $skipAndLockStateClass = 'onp-sl-skip-lock-2-state';
}
$ruleStateClass = '';
$defaultWay = 'skip-lock';
if ( !empty($options) ) $defaultWay = $options['way'];
$skipNumber = 1;
if ( !empty($options) && $options['way'] == 'skip-lock' ) {
$skipNumber = intval( $options['skip_number'] );
}
$cssSelector = '';
if ( !empty($options) && $options['way'] == 'css-selector' ) {
$cssSelector = urldecode( $options['css_selector'] );
}
$excludePosts = '';
if ( !empty($options) && !empty( $options['exclude_posts'] ) ) {
$excludePosts = implode(', ', $options['exclude_posts']);
$ruleStateClass .= ' onp-sl-exclude-post-ids-rule-state';
}
$excludeCategories = '';
if ( !empty($options) && !empty( $options['exclude_categories'] ) ) {
$excludeCategories = implode(', ', $options['exclude_categories']);
$ruleStateClass .= ' onp-sl-exclude-categories-ids-rule-state';
}
$postTypes = '';
if ( !empty($options) && !empty( $options['post_types'] ) ) {
$postTypes = implode(', ', $options['post_types'] );
$ruleStateClass .= ' onp-sl-post-types-rule-state';
}
$checkedPostTypes = array('post', 'page');
if ( !empty($options) && !empty( $options['post_types'] ) ) {
$checkedPostTypes = $options['post_types'];
}
$types = get_post_types( array('public' => true), 'objects' );
// get interrelated option
$interrelated = get_option('opanda_interrelation', false);
$interrelatedClass = ( !$interrelated ) ? 'onp-sl-not-interrelation' : '';
?>
<script>
if ( !window.bizpanda ) window.bizpanda = {};
if ( !window.bizpanda.lang ) window.bizpanda.lang = {};
window.bizpanda.lang.everyPostWillBeLockedEntirelyExceptFirstsParagraphs =
"<?php _e('Every post will be locked entirely except %s paragraphs placed at the beginning.', 'bizpanda') ?>";
window.bizpanda.lang.appliesToTypes =
"<?php _e('Applies to types: %s', 'bizpanda') ?>";
window.bizpanda.lang.excludesPosts =
"<?php _e('Excludes posts: %s', 'bizpanda') ?>";
window.bizpanda.lang.excludesCategories =
"<?php _e('Excludes categories: %s', 'bizpanda') ?>";
</script>
<div class="onp-sl-visibility-options-disabled" style="display: none;">
<div class="alert alert-warning">
<?php _e( 'You set the the batch locking based on CSS Selector. The visibility options don\'t support CSS selectors.', 'bizpanda') ?>
</div>
</div>
<div id="onp-sl-bulk-lock-options">
<?php if ( !empty($options) ) { ?>
<?php foreach( $options as $optionKey => $optionValue ) { ?>
<?php if (in_array($optionKey, array('exclude_posts','exclude_categories','post_types'))) {
$optionValue = implode(',', $optionValue);
} ?>
<input type="hidden" name="onp_sl_<?php echo $optionKey ?>" value="<?php echo $optionValue ?>" />
<?php } ?>
<?php } ?>
</div>
<div class="factory-bootstrap-331 factory-fontawesome-320">
<div class="onp-sl-description-section">
<?php _e('Batch Locking allows to apply the locker shortcode to your posts automatically.', 'bizpanda') ?>
</div>
<div class="onp-sl-setup-section <?php echo $setupStateClass ?>">
<div class="onp-sl-empty-content">
<span class="onp-sl-nolock"><?php _e('No batch lock', 'bizpanda') ?></span>
<a class="btn btn-default" href="#onp-sl-bulk-lock-modal" role="button" data-toggle="factory-modal">
<i class="fa fa-cog"></i> <?php _e('Setup Batch Lock', 'bizpanda') ?>
</a>
</div>
<div class="onp-sl-has-options-content <?php echo $wayStateClass ?> <?php echo $ruleStateClass ?>">
<div class="onp-sl-way-description onp-sl-skip-lock-content <?php echo $skipAndLockStateClass ?>">
<span class="onp-sl-skip-lock-0-content">
<?php echo _e('Every post will be locked entirely.', 'bizpanda') ?>
</span>
<span class="onp-sl-skip-lock-1-content">
<?php echo _e('Every post will be locked entirely except the first paragraph.', 'bizpanda') ?>
</span>
<span class="onp-sl-skip-lock-2-content">
<?php echo sprintf( __('Every post will be locked entirely except %s paragraphs placed at the beginning.', 'bizpanda'), $skipNumber ) ?>
</span>
</div>
<div class="onp-sl-way-description onp-sl-more-tag-content">
<?php echo _e('Content placed after the More Tag will be locked in every post.', 'bizpanda') ?>
</div>
<div class="onp-sl-way-description onp-sl-css-selector-content">
<p><?php echo _e('Every content matching the given CSS selector will be locked on every page:', 'bizpanda') ?></p>
<p><strong class="onp-sl-css-selector-view"><?php echo $cssSelector ?></strong></p>
</div>
<div class='onp-sl-rules'>
<span class='onp-sl-post-types-rule'>
<?php printf( __('Applies to types: %s', 'bizpanda'), $postTypes ) ?>
</span>
<span class='onp-sl-exclude-post-ids-rule'>
<?php printf( __('Excludes posts: %s', 'bizpanda'), $excludePosts ) ?>
</span>
<span class='onp-sl-exclude-categories-ids-rule'>
<?php printf( __('Excludes categories: %s', 'bizpanda'), $excludeCategories ) ?>
</span>
</div>
<div class="onp-sl-controls">
<a class="btn btn-primary onp-sl-cancel" href="#onp-sl-bulk-lock-modal" role="button" data-toggle="modal" id="onp-sl-setup-bult-locking-btn">
<i class="fa fa-times-circle"></i> <?php _e('Cancel', 'bizpanda') ?>
</a>
<a class="btn btn-primary onp-sl-setup-bulk-locking" href="#onp-sl-bulk-lock-modal" role="button" data-toggle="factory-modal">
<i class="fa fa-cog"></i> <?php _e('Setup Batch Lock', 'bizpanda') ?>
</a>
</div>
</div>
</div>
<div class="<?php echo $setupStateClass ?> <?php echo $interrelatedClass ?> onp-sl-interrelation-hint">
<?php printf( __('Recommended to turn on the Interrelation option on the <a target="_blank" href="%s">Common Settings</a> page. It allows to unlock all lockers when one is unlocked.', 'bizpanda'), opanda_get_admin_url("settings", array( 'opanda_screen' => 'lock' ) ) ) ?>
</div>
<div class="onp-sl-after-change-hint">
<i class="fa fa-exclamation-triangle"></i>
<?php _e('Don\'t forget to apply made changes via the Update button above.', 'bizpanda') ?>
</div>
<div class="modal fade" id="onp-sl-bulk-lock-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel"><?php _e('Select Way Of Batch Locking', 'bizpanda') ?></h4>
</div>
<div class="modal-body">
<div class="btn-group" id="onp-sl-bulk-locking-way-selector" data-toggle="buttons-radio">
<button data-target="#onp-sl-skip-lock-options" type="button" class="btn btn-default value skip-lock <?php if ( $defaultWay == 'skip-lock') echo 'active'; ?>" data-name="skip-lock"><i class="fa fa-sort-amount-desc"></i> <?php _e('Skip & Lock', 'bizpanda' ) ?></button>
<button data-target="#onp-sl-more-tags-options" type="button" class="btn btn-default value more-tag <?php if ( $defaultWay == 'more-tag') echo 'active'; ?>" data-name="more-tag"><i class="fa fa-scissors"></i> <?php _e('More Tag', 'bizpanda' ) ?></button>
<button data-target="#onp-sl-css-selector-options" type="button" class="btn btn-default value css-selector <?php if ( $defaultWay == 'css-selector') echo 'active'; ?>" data-name="css-selector"><i class="fa fa-hand-o-up"></i> <?php _e('CSS Selector', 'bizpanda' ) ?></button>
</div>
<div id="onp-sl-skip-lock-options" class="onp-sl-bulk-locking-options <?php if ( $defaultWay !== 'skip-lock') echo 'hide'; ?>">
<div class="onp-sl-description">
<?php _e('Enter the number of paragraphs which will be visible for users at the beginning of your posts and which will be free from locking. The remaining paragraphs will be locked.', 'bizpanda') ?>
</div>
<div class="onp-sl-content">
<div class="onp-sl-form">
<div class='onp-sl-skip-number-row'>
<label><?php _e('The number of paragraphs to skip', 'bizpanda') ?></label>
<input type="text" class="form-control onp-sl-skip-number" maxlength="3" min="0" value="<?php echo $skipNumber; ?>" />
<div class="help-block help-block-error">
<?php _e('Please enter a positive integer value.') ?>
</div>
</div>
<div class="onp-sl-limits">
<div class='onp-sl-exclude'>
<div class='onp-sl-row'>
<label><?php _e('Exclude Posts', 'bizpanda') ?></label>
<input type="text" class="form-control onp-sl-exclude-posts" value="<?php echo $excludePosts; ?>" />
<div class="help-block">
<?php _e('(Optional) Enter posts IDs comma separated, for example, "19,25,33".', 'bizpanda') ?>
</div>
</div>
<div class='onp-sl-row'>
<label><?php _e('Exclude Categories', 'bizpanda') ?></label>
<input type="text" class="form-control onp-sl-exclude-categories" value="<?php echo $excludeCategories; ?>" />
<div class="help-block">
<?php _e('(Optional) Enter categories IDs comma separated, for example, "4,7".', 'bizpanda') ?>
</div>
</div>
</div>
<div class='onp-sl-post-types'>
<strong><?php _e('Posts types to lock', 'bizpanda') ?></strong>
<div class="help-block">
<?php _e('Choose post types for batch locking.', 'bizpanda') ?>
</div>
<ul>
<?php foreach($types as $type) {?>
<li>
<label for='onp-sl-post-type-<?php echo $type->name ?>-lock-skip'>
<input type='checkbox' class='onp-sl-post-type onp-sl-<?php echo $type->name ?>' id='onp-sl-post-type-<?php echo $type->name ?>-lock-skip' value='<?php echo $type->name ?>' <?php if ( in_array($type->name, $checkedPostTypes ) ) { echo 'checked="checked"'; } ?> />
<?php echo $type->label ?>
</label>
</li>
<?php } ?>
</ul>
<div class="help-block help-block-error">
<?php _e('Please choose at least one post type to lock. Otherwise, nothing to lock.', 'bizpanda') ?>
</div>
</div>
</div>
</div>
<div class="onp-sl-example">
<div class="onp-sl-description">
<strong><?php _e('For example,', 'bizpanda') ?></strong>
<?php _e('If you enter 2, two first paragraphs will be visible, others will be locked.', 'bizpanda') ?>
</div>
<div class="onp-sl-page">
<div class="onp-sl-skipped">
<div class="onp-sl-p"></div>
<div class="onp-sl-p"></div>
</div>
<div class="onp-sl-locked">
<div class="onp-sl-hint">
<i class="fa fa-lock"></i>
<?php _e('this will be locked', 'bizpanda') ?>
<i class="fa fa-lock"></i>
</div>
<div class="onp-sl-p"></div>
<div class="onp-sl-p"></div>
<div class="onp-sl-p"></div>
</div>
</div>
</div>
</div>
</div>
<div id="onp-sl-more-tags-options" class="onp-sl-bulk-locking-options <?php if ( $defaultWay !== 'more-tag') echo 'hide'; ?>">
<div class="onp-sl-description">
<?php _e('All content after the More Tag will be locked in all your posts. If a post doesn\'t have the More Tag, the post will be shown without locking.', 'bizpanda') ?>
</div>
<div class="onp-sl-content">
<div class="onp-sl-form onp-sl-limits">
<div class='onp-sl-exclude'>
<div class='onp-sl-row'>
<label><?php _e('Exclude Posts', 'bizpanda') ?></label>
<input type="text" class="form-control onp-sl-exclude-posts" value="<?php echo $excludePosts; ?>" />
<div class="help-block">
<?php _e('(Optional) Enter posts IDs comma separated, for example, "19,25,33".', 'bizpanda') ?>
</div>
</div>
<div class='onp-sl-row'>
<label><?php _e('Exclude Categories', 'bizpanda') ?></label>
<input type="text" class="form-control onp-sl-exclude-categories" value="<?php echo $excludeCategories; ?>" />
<div class="help-block">
<?php _e('(Optional) Enter categories IDs comma separated, for example, "4,7".', 'bizpanda') ?>
</div>
</div>
</div>
<div class='onp-sl-post-types'>
<strong><?php _e('Posts types to lock', 'bizpanda') ?></strong>
<div class="help-block">
<?php _e('Choose post types for batch locking.', 'bizpanda') ?>
</div>
<ul>
<?php foreach($types as $type) {?>
<li>
<label for='onp-sl-post-type-<?php echo $type->name ?>-more-tag'>
<input type='checkbox' class='onp-sl-post-type onp-sl-<?php echo $type->name ?>' id='onp-sl-post-type-<?php echo $type->name ?>-more-tag' value='<?php echo $type->name ?>' <?php if ( in_array($type->name, $checkedPostTypes ) ) { echo 'checked="checked"'; } ?> />
<?php echo $type->label ?>
</label>
</li>
<?php } ?>
</ul>
<div class="help-block help-block-error">
<?php _e('Please choose at least one post type to lock. Otherwise, nothing to lock.', 'bizpanda') ?>
</div>
</div>
</div>
<strong class="onp-sl-title"><?php _e('What is the More Tag?', 'bizpanda') ?></strong>
<div class="onp-sl-image"></div>
<p>
<?php _e('Check out <a href="http://en.support.wordpress.com/splitting-content/more-tag/" target="_blank">Splitting Content > More Tag</a> to lean more.', 'bizpanda') ?>
</p>
</div>
</div>
<div id="onp-sl-css-selector-options" class="onp-sl-bulk-locking-options <?php if ( $defaultWay !== 'css-selector') echo 'hide'; ?>">
<div class="onp-sl-description">
<p>
<?php _e('CSS selectors allow accurately choose which content will be locked by usign CSS classes or IDs of elements placed on pages. If you don\'t know what is it, please don\'t use it.', 'bizpanda') ?>
</p>
<p>
<?php _e('Check out <a href="http://www.w3schools.com/cssref/css_selectors.asp" target="_blank">CSS Selector Reference</a> to lean more.', 'bizpanda') ?>
</p>
</div>
<div class="onp-sl-content">
<div class="onp-sl-form">
<label><?php _e('CSS Selector', 'bizpanda') ?></label>
<input type="text" class="form-control onp-sl-css-selector" value="<?php echo htmlentities($cssSelector); ?>" />
<div class="help-block">
<?php _e('For example, "#somecontent .my-class, .my-another-class"', 'bizpanda') ?>
</div>
<div class="help-block help-block-error">
<?php _e('Please enter a css selector to lock.', 'bizpanda') ?>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php _e('Cancel', 'bizpanda') ?></button>
<button type="button" class="btn btn-primary" id="onp-sl-save-bulk-locking-btn"><?php _e('Save', 'bizpanda') ?></button>
</div>
</div>
</div>
</div>
</div>
<?php
}
public function addBulkLockingWayCssClass( $classes ) {
$classes[] = $this->way;
return $classes;
}
public function save( $postId ) {
// clear previos settings
$bulkLockers = get_option('onp_sl_bulk_lockers', array());
if ( !is_array($bulkLockers) ) $bulkLockers = array();
if ( isset( $bulkLockers[$postId] ) ) unset( $bulkLockers[$postId] );
if ( !isset( $_POST['onp_sl_way'] ) ) {
delete_post_meta($postId, 'opanda_bulk_locking');
delete_option('onp_sl_bulk_lockers');
add_option('onp_sl_bulk_lockers', $bulkLockers);
return;
} else {
$way = $_POST['onp_sl_way'];
if ( !in_array( $way, array( 'skip-lock', 'more-tag', 'css-selector' )) ) {
delete_post_meta($postId, 'opanda_bulk_locking');
delete_option('onp_sl_bulk_lockers');
add_option('onp_sl_bulk_lockers', $bulkLockers);
return;
}
$data = array('way' => $way);
if ( $way == 'skip-lock' ) {
$data['skip_number'] = intval( $_POST['onp_sl_skip_number'] );
} elseif( $way == 'css-selector' ) {
$data['css_selector'] = $_POST['onp_sl_css_selector'];
}
if ( $way == 'skip-lock' || $way == 'more-tag' ) {
$postTypes = isset( $_POST['onp_sl_post_types'] ) ? $_POST['onp_sl_post_types'] : '';
$excludePosts = isset( $_POST['onp_sl_exclude_posts'] ) ? $_POST['onp_sl_exclude_posts'] : '';
$excludeCategories = isset( $_POST['onp_sl_exclude_categories'] ) ? $_POST['onp_sl_exclude_categories'] : '';
$data['post_types'] = explode ( ',', $postTypes );
$data['post_types'] = !empty( $data['post_types'] ) ? array_map( 'trim', $data['post_types'] ) : array();
$data['exclude_posts'] = !empty( $excludePosts )
? $this->_normalizeIntValArray( explode ( ',', $excludePosts ) )
: array();
$data['exclude_categories'] = !empty( $excludeCategories )
? $this->_normalizeIntValArray( explode ( ',', $excludeCategories ) )
: array();
}
$bulkLockers[$postId] = $data;
delete_option('onp_sl_bulk_lockers');
add_option('onp_sl_bulk_lockers', $bulkLockers);
update_post_meta($postId, 'opanda_bulk_locking', $data);
}
}
function _normalizeIntValArray( $arr ) {
$arr = !empty( $arr ) ? array_map( 'intval', $arr ) : array();
$return = array();
foreach( $arr as $value ) {
if ( $value == 0 ) continue;
$return[] = $value;
}
return $return;
}
}
global $bizpanda;
FactoryMetaboxes321::register('OPanda_BulkLockingMetaBox', $bizpanda);

View File

@@ -0,0 +1,96 @@
<?php
/**
* The file contains a class to configure the metabox Bulk Locking.
*
* Created via the Factory Metaboxes.
*
* @author Paul Kashtanoff <paul@byonepress.com>
* @copyright (c) 2013, OnePress Ltd
*
* @package core
* @since 1.0.0
*/
/**
* The class to show info on how the plugin support is provided.
*
* @since 1.0.0
*/
class OPanda_ManualLockingMetaBox extends FactoryMetaboxes321_Metabox
{
/**
* A visible title of the metabox.
*
* Inherited from the class FactoryMetabox.
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
*
* @since 1.0.0
* @var string
*/
public $title;
/**
* The priority within the context where the boxes should show ('high', 'core', 'default' or 'low').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $priority = 'core';
/**
* The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $context = 'side';
public function __construct( $plugin ) {
parent::__construct( $plugin );
$this->title = __('Manual Locking <i>(recommended)</i>', 'bizpanda');
}
public function configure( $scripts, $styles ){
$scripts->add( OPANDA_BIZPANDA_URL . '/assets/admin/js/metaboxes/manual-lock.010000.js');
}
/**
* Renders content of the metabox.
*
* @see FactoryMetaboxes321_Metabox
* @since 1.0.0
*
* @return void
*/
public function html()
{
global $post;
$isSystem = get_post_meta( $post->ID, 'opanda_is_system', true);
$item = OPanda_Items::getCurrentItem();
$shortcodeName = $item['shortcode'];
$shortcode = '[' . $shortcodeName . '] [/' . $shortcodeName . ']';
if (!$isSystem) $shortcode = '[' . $shortcodeName . ' id="' . $post->ID . '"] [/' . $shortcodeName . ']';
?>
<div class="factory-bootstrap-331 factory-fontawesome-320">
<p class="onp-sl-description-section">
<?php _e('Wrap content you want to lock via the following shortcode in your post editor:', 'bizpanda') ?>
<input class="onp-sl-shortcode" type="text" value='<?php echo $shortcode ?>' />
</p>
</div>
<?php
}
}
global $bizpanda;
FactoryMetaboxes321::register('OPanda_ManualLockingMetaBox', $bizpanda);

View File

@@ -0,0 +1,122 @@
<?php
/**
* The file contains a metabox to show the Locker Preview.
*
* Created via the Factory Metaboxes.
*
* @author Paul Kashtanoff <paul@byonepress.com>
* @copyright (c) 2013, OnePress Ltd
*
* @package core
* @since 1.0.0
*/
/**
* The class to render the metabox Locker Preview'.
*
* @since 1.0.0
*/
class OPanda_PreviewMetaBox extends FactoryMetaboxes321_Metabox
{
/**
* A visible title of the metabox.
*
* Inherited from the class FactoryMetabox.
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
*
* @since 1.0.0
* @var string
*/
public $title;
/**
* The priority within the context where the boxes should show ('high', 'core', 'default' or 'low').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $priority = 'core';
public function __construct( $plugin ) {
parent::__construct( $plugin );
$this->title = __('Locker Preview', 'bizpanda');
}
/**
* Renders content of the metabox.
*
* @see FactoryMetaboxes321_Metabox
* @since 1.0.0
*
* @return void
*/
public function html()
{
global $bizpanda;
$query_string = '?action=onp_sl_preview';
$query_string = apply_filters('opanda_preview_url', $query_string);
$extra_data = array();
$extra_data['data-url'] = admin_url('admin-ajax.php') . $query_string;
$extra_data = apply_filters('onp_sl_preview_data_wrap', $extra_data);
// ToDo: remove, it's obsoleted
$dataPrint = sizeof($extra_data) ? ' ' : '';
foreach( $extra_data as $key => $val) $dataPrint .= $key.'="'.$val.'" ';
$dataPrint = rtrim($dataPrint, ' ');
$showStyleRollerOffer = ( BizPanda::isSinglePlugin() && BizPanda::hasPlugin('sociallocker') );
?>
<script>
function onp_sl_update_preview_height(height) {
jQuery("#lock-preview-wrap iframe").height(height);
}
var pluginName = '<?php echo $bizpanda->pluginName; ?>';
window.opanda_proxy_url = '<?php echo opanda_local_proxy_url() ?>';
window.opanda_terms = '<?php echo opanda_terms_url() ?>';
window.opanda_privacy_policy = '<?php echo opanda_privacy_policy_url() ?>';
window.opanda_privacy_policy_title = '<?php echo get_option('opanda_res_misc_privacy_policy', __('Privacy Policy', 'bizpanda') ) ?>';
window.opanda_subscription_service_name = '<?php echo get_option('opanda_subscription_service', 'none') ?>';
window.opanda_site_name = '<?php echo get_bloginfo("name") ?>';
window.opanda_home_url = '<?php echo get_home_url() ?>';
<?php if ( defined('ONP_OP_STYLER_PLUGIN_ACTIVE') ) { ?>
window.onp_sl_styleroller = true;
<?php } else { ?>
window.onp_sl_styleroller = false;
window.onp_sl_styleroller_offer_text = '<?php _e('Want more themes?', 'bizpanda') ?>';
window.onp_sl_styleroller_offer_url = '<?php echo $bizpanda->options['styleroller'] ?>';
<?php } ?>
<?php if ( $showStyleRollerOffer ) { ?>
window.onp_sl_show_styleroller_offer = true;
<?php } else { ?>
window.onp_sl_show_styleroller_offer = false;
<?php } ?>
</script>
<?php do_action('bizpanda_print_preview_variables') ?>
<p class="note"><strong><?php _e('Note', 'bizpanda'); ?>:</strong> <?php _e('In the preview mode, some features of the locker may not work properly.', 'bizpanda'); ?></p>
<div id="lock-preview-wrap"<?php echo $dataPrint; ?>>
<iframe
allowtransparency="1"
frameborder="0"
hspace="0"
marginheight="0"
marginwidth="0"
name="preview"
vspace="0"
width="100%">
<?php _e('Your browser doen\'t support the iframe tag.', 'bizpanda'); ?>
</iframe>
</div>
<?php
}
}
global $bizpanda;
FactoryMetaboxes321::register('OPanda_PreviewMetaBox', $bizpanda);

View File

@@ -0,0 +1,178 @@
<?php
/**
* The file contains a class to configure the metabox "More Features?".
*
* Created via the Factory Metaboxes.
*
* @author Paul Kashtanoff <paul@byonepress.com>
* @copyright (c) 2013, OnePress Ltd
*
* @package core
* @since 1.0.0
*/
/**
* The class to configure the metabox "More Features?".
*
* @since 1.0.0
*/
class OPanda_TermsOptionsMetaBox extends FactoryMetaboxes321_FormMetabox
{
/**
* A visible title of the metabox.
*
* Inherited from the class FactoryMetabox.
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
*
* @since 1.0.0
* @var string
*/
public $title;
/**
* A prefix that will be used for names of input fields in the form.
*
* Inherited from the class FactoryFormMetabox.
*
* @since 2.3.0
* @var string
*/
public $scope = 'opanda';
/**
* The priority within the context where the boxes should show ('high', 'core', 'default' or 'low').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $priority = 'core';
/**
* The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 1.0.0
* @var string
*/
public $context = 'side';
public function __construct( $plugin ) {
parent::__construct( $plugin );
$this->title = __('Terms & Policies', 'bizpanda');
}
public $cssClass = 'factory-bootstrap-331 factory-fontawesome-320';
public function configure( $scripts, $styles ){
$scripts->add( OPANDA_BIZPANDA_URL . '/assets/admin/js/metaboxes/terms.010000.js');
}
/**
* Configures a form that will be inside the metabox.
*
* @see FactoryMetaboxes321_FormMetabox
* @since 1.0.0
*
* @param FactoryForms328_Form $form A form object to configure.
* @return void
*/
public function form( $form ) {
$itemType = OPanda_Items::getCurrentItem();
$hint = __('Consent Checkbox for GDPR compatibility.', 'bizpanda');
if ( 'social-locker' === $itemType['name'] ) {
$hint = sprintf( __('Consent Checkbox for <a href="%s" target="_blank">GDPR compatibility.</a>', 'bizpanda'), opanda_get_help_url('gdpr-social-locker') );
} elseif ( 'signin-locker' === $itemType['name'] ) {
$hint = sprintf( __('Consent Checkbox for <a href="%s" target="_blank">GDPR compatibility.</a>', 'bizpanda'), opanda_get_help_url('gdpr-signin-locker') );
} elseif ( 'email-locker' === $itemType['name'] ) {
$hint = sprintf( __('Consent Checkbox for <a href="%s" target="_blank">GDPR compatibility.</a>', 'bizpanda'), opanda_get_help_url('gdpr-email-locker') );
}
$options = array(
array(
'type' => 'html',
'html' => array(&$this, 'showTermsContentNote')
),
array(
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'agreement_checkbox',
'title' => '<i class="fa fa-check-square-o" style="font-size: 17px; margin-right: 8px; top: 2px; position: relative;"></i>' . __('Consent Checkbox', 'bizpanda'),
'hint' => $hint,
'default' => false
),
array(
'type' => 'html',
'html' => array($this, 'htmlConsentCheckboxOption')
),
array(
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'agreement_note',
'title' => '<i class="fa fa-flag" style="font-size: 17px; margin-right: 8px;"></i>' . __('Footer Reference', 'bizpanda'),
'hint' => __('Shows a reference to Terms & Policies at bottom.', 'bizpanda'),
'default' => false
),
);
$options = apply_filters('opanda_terms_and_policies_options', $options);
$form->add($options);
}
public function htmlConsentCheckboxOption() {
$consentCheckbox = $this->provider->getValue('agreement_checkbox', false);
$checkboxPosiion = $this->provider->getValue('agreement_checkbox_position', 'bottom');
if ( empty($checkboxPosiion) ) $checkboxPosiion = 'bottom';
?>
<div class='onp-sl-sub <?php if ( !$consentCheckbox ) { echo 'hide'; } ?>' id='onp-sl-agreement_checkbox-options'>
<label class='control-label' style="margin-bottom: 5px;"><?php _e('The checkbox will appear at:', 'bizpanda') ?></label>
<select class='form-control' name='<?php echo $this->scope ?>_agreement_checkbox_position' id="<?php echo $this->scope ?>_agreement_checkbox_position">
<option value='top' <?php selected('top', $checkboxPosiion) ?>><?php _e('Top', 'bizpanda') ?></option>
<option value='bottom' <?php selected('bottom', $checkboxPosiion) ?>><?php _e('Bottom', 'bizpanda') ?></option>
</select>
</div>
<?php
}
public function showTermsContentNote() {
?>
<?php printf( __('You can change content of your Terms & Policies pages <a href="%s" target="_blank">here</a>.'), admin_url('admin.php?page=settings-' . $this->plugin->pluginName . '&opanda_screen=terms&action=index') ) ?>
<?php
}
/**
* Saves some extra options.
*/
public function onSavingForm( $post_id) {
parent::onSavingForm( $post_id );
$checkbox = isset( $_POST[$this->scope . '_agreement_checkbox'] )
? $_POST[$this->scope . '_agreement_checkbox']
: false;
$position = isset( $_POST[$this->scope . '_agreement_checkbox_position'] )
? $_POST[$this->scope . '_agreement_checkbox_position']
: 'bottom';
if ( !$checkbox ) $position = false;
$this->provider->setValue('agreement_checkbox_position', $position );
}
}
global $bizpanda;
FactoryMetaboxes321::register('OPanda_TermsOptionsMetaBox', $bizpanda);

View File

@@ -0,0 +1,670 @@
<?php
/**
* The file contains a class to configure the metabox Visibility Options.
*
* Created via the Factory Metaboxes.
*
* @author Paul Kashtanoff <paul@byonepress.com>
* @copyright (c) 2013, OnePress Ltd
*
* @package core
* @since 2.3.0
*/
/**
* The class to configure the metabox Visibility Options.
*
* @since 2.3.0
*/
class OPanda_VisabilityOptionsMetaBox extends FactoryMetaboxes321_FormMetabox
{
/**
* A visible title of the metabox.
*
* Inherited from the class FactoryMetabox.
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
*
* @since 2.3.0
* @var string
*/
public $title;
/**
* A prefix that will be used for names of input fields in the form.
*
* Inherited from the class FactoryFormMetabox.
*
* @since 2.3.0
* @var string
*/
public $scope = 'opanda';
/**
* The priority within the context where the boxes should show ('high', 'core', 'default' or 'low').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 2.3.0
* @var string
*/
public $priority = 'core';
/**
* The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side').
*
* @link http://codex.wordpress.org/Function_Reference/add_meta_box
* Inherited from the class FactoryMetabox.
*
* @since 2.3.0
* @var string
*/
public $context = 'side';
public function __construct( $plugin ) {
parent::__construct( $plugin );
$this->title = __('Visibility Options', 'bizpanda');
}
public $cssClass = 'factory-bootstrap-331 factory-fontawesome-320';
public function configure( $scripts, $styles ){
$scripts->add( OPANDA_BIZPANDA_URL . '/assets/admin/js/widgets/condition-editor.010000.js');
$scripts->add( OPANDA_BIZPANDA_URL . '/assets/admin/js/metaboxes/visability.010001.js');
}
/**
* Configures a form that will be inside the metabox.
*
* @see FactoryMetaboxes321_FormMetabox
* @since 1.0.0
*
* @param FactoryForms328_Form $form A form object to configure.
* @return void
*/
public function form( $form ) {
$options = array(
array(
'type' => 'html',
'html' => array($this, 'htmlSwitcher')
),
array(
'type' => 'hidden',
'name' => 'visibility_mode',
'default' => 'simple'
),
array(
'type' => 'div',
'id' => 'bp-simple-visibility-options',
'items' => array(
array(
'type' => 'textbox',
'name' => 'delay',
'title' => __('Lock Delay', 'bizpanda'),
'hint' => __('Displays the locker after the specified interval (in seconds).', 'bizpanda'),
'icon' => OPANDA_BIZPANDA_URL . '/assets/admin/img/timer-icon.png',
'default' => false
),
array(
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'hide_for_member',
'title' => __('Hide For Members', 'bizpanda'),
'hint' => __('If on, hides the locker for registered members.', 'bizpanda'),
'icon' => OPANDA_BIZPANDA_URL . '/assets/admin/img/member-icon.png',
'default' => false
),
array(
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'relock',
'title' => __('ReLock', 'bizpanda'),
'hint' => __('If on, being unlocked the locker will appear again after a specified interval.', 'bizpanda'),
'icon' => OPANDA_BIZPANDA_URL . '/assets/admin/img/icon-relock-3.png',
'default' => false
),
array(
'type' => 'html',
'html' => array($this, 'htmlReLockOptions')
),
array(
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'always',
'title' => '<i class="fa fa-umbrella" style="font-size: 17px; margin-right: 8px;"></i>' . __('Show Always', 'bizpanda'),
'hint' => __('If on, the locker appears always even it was unlocked.', 'bizpanda'),
'default' => false
),
array(
'type' => 'checkbox',
'way' => 'buttons',
'name' => 'mobile',
'title' => __('Mobile', 'bizpanda'),
'hint' => __('If on, the locker will appear on mobile devices.', 'bizpanda'),
'icon' => OPANDA_BIZPANDA_URL . '/assets/admin/img/mobile-icon.png',
'default' => true
)
)
),
array(
'type' => 'div',
'id' => 'bp-advanced-visibility-options',
'items' => array(
array(
'type' => 'html',
'html' => array( $this, 'visibilityFilters' )
),
array(
'type' => 'hidden',
'name' => 'visibility_filters'
)
)
)
);
if ( OPanda_Items::isCurrentFree() ) {
$options[] = array(
'type' => 'html',
'html' => '<div style="display: none;" class="factory-fontawesome-320 opanda-overlay-note opanda-premium-note">' . __( '<i class="fa fa-star-o"></i> Go Premium <i class="fa fa-star-o"></i><br />To Unlock These Features <a href="#" class="opnada-button">Learn More</a>', 'bizpanda' ) . '</div>'
);
}
$options = apply_filters( 'opanda_visability_options', $options, $this );
$form->add( $options );
}
public function htmlReLockOptions() {
$relock = $this->provider->getValue('relock', false);
$interval = $this->provider->getValue('relock_interval', 0);
if ( $interval == 0 ) $interval = '';
$units = $this->provider->getValue('relock_interval_units', 'days');
?>
<div class='onp-sl-sub <?php if ( !$relock ) { echo 'hide'; } ?>' id='onp-sl-relock-options'>
<label class='control-label'><?php _e('The locker will reappear after:', 'bizpanda') ?></label>
<input type='text' class='form-control input' name='<?php echo $this->scope ?>_relock_interval' value='<?php echo $interval ?>' />
<select class='form-control' name='<?php echo $this->scope ?>_relock_interval_units'>
<option value='days' <?php selected('days', $units) ?>><?php _e('day(s)', 'bizpanda') ?></option>
<option value='hours' <?php selected('hours', $units) ?>><?php _e('hour(s)', 'bizpanda') ?></option>
<option value='minutes' <?php selected('minutes', $units) ?>><?php _e('minute(s)', 'bizpanda') ?></option>
</select>
<p style="margin: 6px 0 0 0; font-size: 12px;"><?php _e('Any changes will apply only for new users.', 'bizpanda') ?></p>
</div>
<?php
}
/**
* Shows html for the options' switcher.
*/
public function htmlSwitcher() {
?>
<div class="bp-options-switcher">
<span class="bp-label"><?php _e('Options Mode:', 'bizpanda') ?></span>
<div class="btn-group bp-swither-ctrl">
<a href="#" class="btn btn-sm btn-default btn-btn-simple" data-value="simple"><?php _e('Simple', 'bizpanda') ?></a>
<a href="#" class="btn btn-sm btn-default btn-btn-advanced" data-value="advanced"><?php _e('Advanced', 'bizpanda') ?></a>
</div>
</div>
<?php
}
/**
* Shows a popup to display advanded options.
*/
public function visibilityFilters() {
// filter parameters
$groupedFilterParams = array(
array(
'id' => 'user',
'title' => __('User', 'bizpanda'),
'items' => array(
array(
'id' => 'user-role',
'title' =>__('Role', 'bizpanda'),
'type' => 'select',
'values' => array(
'type' => 'ajax',
'action' => 'bp_ajax_get_user_roles'
),
'description' => __('A role of the user who views your website. The role "guest" is applied to unregistered users.', 'bizpanda')
),
array(
'id' => 'user-registered',
'title' =>__('Registration Date', 'bizpanda'),
'type' => 'date',
'description' => __('The date when the user who views your website was registered. For unregistered users this date always equals to 1 Jan 1970.', 'bizpanda')
),
array(
'id' => 'user-mobile',
'title' =>__('Mobile Device', 'bizpanda'),
'type' => 'select',
'values' => array(
array('value' => 'yes', 'title' => __('Yes', 'bizpanda') ),
array('value' => 'no', 'title' => __('No', 'bizpanda') )
),
'description' => __('Determines whether the user views your website from mobile device or not.', 'bizpanda')
),
array(
'id' => 'user-cookie-name',
'title' =>__('Cookie Name', 'bizpanda'),
'type' => 'text',
'onlyEquals' => true,
'description' => __('Determines whether the user\'s browser has a cookie with a given name.', 'bizpanda')
)
)
),
array(
'id' => 'session',
'title' => __('Session', 'bizpanda'),
'items' => array(
array(
'id' => 'session-pageviews',
'title' =>__('Total Pageviews', 'bizpanda'),
'type' => 'integer',
'description' => sprintf( __('The total count of pageviews made by the user within one\'s current session on your website. You can specify a duration of the sessions <a href="%s" target="_blank">here</a>.', 'bizpanda'), opanda_get_admin_url('settings', array('opanda_screen' => 'lock') ) )
),
array(
'id' => 'session-locker-pageviews',
'title' =>__('Locker Pageviews', 'bizpanda'),
'type' => 'integer',
'description' => sprintf( __('The count of views of pages where lockers located, made by the user within one\'s current session on your website. You can specify a duration of the sessions <a href="%s" target="_blank">here</a>.', 'bizpanda'), opanda_get_admin_url('settings', array('opanda_screen' => 'lock') ) )
),
array(
'id' => 'session-landing-page',
'title' =>__('Landing Page', 'bizpanda'),
'type' => 'text',
'description' => sprintf( __('A page of your website from which the user starts one\'s current session. You can specify a duration of the sessions <a href="%s" target="_blank">here</a>.', 'bizpanda'), opanda_get_admin_url('settings', array('opanda_screen' => 'lock') ) )
),
array(
'id' => 'session-referrer',
'title' =>__('Referrer', 'bizpanda'),
'type' => 'text',
'description' => sprintf( __('A referrer URL which has brought the user to your website within the user\'s current session. You can specify a duration of the sessions <a href="%s" target="_blank">here</a>.', 'bizpanda'), opanda_get_admin_url('settings', array('opanda_screen' => 'lock') ) )
)
)
),
array(
'id' => 'location',
'title' => __('Location', 'bizpanda'),
'items' => array(
array(
'id' => 'location-page',
'title' =>__('Current Page', 'bizpanda'),
'type' => 'text',
'description' => __('An URL of the current page where a user who views your website is located.', 'bizpanda')
),
array(
'id' => 'location-referrer',
'title' =>__('Current Referrer', 'bizpanda'),
'type' => 'text',
'description' => __('A referrer URL which has brought a user to the current page.', 'bizpanda')
)
)
),
array(
'id' => 'post',
'title' => __('Post', 'bizpanda'),
'items' => array(
array(
'id' => 'post-published',
'title' =>__('Publication Date', 'bizpanda'),
'type' => 'date',
'description' => __('The publication date of a post where a user who views your website is located currently.', 'bizpanda')
)
)
),
);
$groupedFilterParams = apply_filters('bp_visibility_filter_params', $groupedFilterParams);
$filterParams = array();
foreach( $groupedFilterParams as $filterGroup ) {
$filterParams = array_merge( $filterParams, $filterGroup['items'] );
}
// templates
$templates = array(
array(
'id' => 'hide_for_members',
'title' => __('[Hide For Members]: Show the locker only for guests', 'bizpanda'),
'filter' => array(
'type' => 'showif',
'conditions' => array(
array(
'type' => 'condition',
'param' => 'user-role',
'operator' => 'equals',
'value' => 'guest'
)
)
)
),
array(
'id' => 'mobile',
'title' => __('[Hide On Mobile]: Hide the locker on mobile devices', 'bizpanda'),
'filter' => array(
'type' => 'hideif',
'conditions' => array(
array(
'type' => 'condition',
'param' => 'user-mobile',
'operator' => 'equals',
'value' => 'yes'
)
)
)
),
array(
'id' => 'delayed_lock',
'title' => __('[Delayed Lock]: Show the locker only in posts older than 5 days', 'bizpanda'),
'filter' => array(
'type' => 'showif',
'conditions' => array(
array(
'type' => 'condition',
'param' => 'post-published',
'operator' => 'older',
'value' => array(
'type' => 'relative',
'unitsCount' => 5,
'units' => 'days'
)
)
)
)
)
);
$templates = apply_filters('bp_visibility_templates', $templates);
?>
<div class="bp-advanded-options">
<div class="bp-button-wrap">
<a class="btn btn-default" href="#bp-advanced-visability-options" role="button" data-toggle="factory-modal">
<i class="fa fa-cog"></i> <?php _e('Setup Visibility Conditions', 'bizpanda') ?>
</a>
</div>
<div class="modal fade bp-model" id="bp-advanced-visability-options" tabindex="-1" role="dialog" aria-labelledby="advancedVisabilityOptions" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel"><?php _e('Visibility Conditions', 'bizpanda') ?></h4>
<p style="margin-bottom: 0px;"><?php _e('Filters are applied consistently. Use templates to set up quickly the most popular conditions.') ?></p>
</div>
<div class="modal-body">
<script>
window.bp = window.bp || {};
window.bp.filtersParams = <?php echo json_encode( $filterParams ) ?>;
window.bp.templates = <?php echo json_encode( $templates ) ?>;
</script>
<div class="bp-editor-wrap">
<div class="bp-when-empty">
<?php _e('No filters specified. <a href="#" class="bp-add-filter">Click here</a> to add one.', 'bizpanda') ?>
</div>
<div class="bp-filters"></div>
</div>
<div class="bp-filter bp-template">
<div class="bp-point"></div>
<div class="bp-head">
<div class="bp-left">
<span style="margin-left: 0px;"><strong>Type:</strong></span>
<select class="bp-filter-type">
<option value="showif"><?php _e('Show Locker IF', 'bizpanda') ?></option>
<option value="hideif"><?php _e('Hide Locker IF', 'bizpanda') ?></option>
</select>
<span>Or</span>
<a href="#" class="button btn-remove-filter"><?php _e('Remove', 'bizpanda') ?></a>
</div>
<div class="bp-templates bp-right">
<span><strong><?php _e('Template', 'bizpanda') ?></strong></span>
<select class="bp-select-template">
<option><?php _e('- select a template -', 'bizpanda') ?></option>
<?php foreach ( $templates as $template ) { ?>
<option value="<?php echo $template['id'] ?>"><?php echo $template['title'] ?></option>
<?php } ?>
</select>
<a href="#" class="button bp-btn-apply-template"><?php _e('Apply', 'bizpanda') ?></a>
</div>
</div>
<div class="bp-box">
<div class="bp-when-empty">
<?php _e('No conditions specified. <a href="#" class="bp-link-add">Click here</a> to add one.', 'bizpanda') ?>
</div>
<div class="bp-conditions"></div>
</div>
</div>
<div class="bp-scope bp-template">
<div class="bp-and"><span><?php _e('and', 'bizpanda') ?></span></div>
</div>
<div class="bp-condition bp-template">
<div class="bp-or"><?php _e('or', 'bizpanda') ?></div>
<span class="bp-params">
<select class="bp-param-select">
<?php foreach( $groupedFilterParams as $filterParam ) { ?>
<optgroup label="<?php echo $filterParam['title'] ?>">
<?php foreach( $filterParam['items'] as $param ) { ?>
<option value="<?php echo $param['id'] ?>">
<?php echo $param['title'] ?>
</option>
<?php } ?>
</optgroup>
<?php } ?>
</select>
<i class="bp-hint">
<span class="bp-hint-icon"></span>
<span class="bp-hint-content"></span>
</i>
</span>
<span class="bp-operators">
<select class="bp-operator-select">
<option value="equals"><?php _e('Equals', 'bizpanda') ?></option>
<option value="notequal"><?php _e('Doesn\'t Equal', 'bizpanda') ?></option>
<option value="greater"><?php _e('Greater Than', 'bizpanda') ?></option>
<option value="less"><?php _e('Less Than', 'bizpanda') ?></option>
<option value="older"><?php _e('Older Than', 'bizpanda') ?></option>
<option value="younger"><?php _e('Younger Than', 'bizpanda') ?></option>
<option value="contains"><?php _e('Contains', 'bizpanda') ?></option>
<option value="notcontain"><?php _e('Doesn\'t Сontain', 'bizpanda') ?></option>
<option value="between"><?php _e('Between', 'bizpanda') ?></option>
</select>
</span>
<span class="bp-value"></span>
<span class="bp-controls">
<div class="btn-group">
<a href="#" class="btn btn-sm btn-default bp-btn-remove">-</a>
<a href="#" class="btn btn-sm btn-default bp-btn-or"><?php _e('OR', 'bizpanda') ?></a>
<a href="#" class="btn btn-sm btn-default bp-btn-and"><?php _e('AND', 'bizpanda') ?></a>
</div>
</span>
</div>
<div class="bp-date-control bp-relative bp-template">
<div class="bp-inputs">
<div class="bp-between-date">
<div class="bp-absolute-date">
<span class="bp-label"> <?php _e('from', 'bizpanda') ?> </span>
<div class="bp-date-control bp-date-start" data-date="today">
<input size="16" type="text" readonly="readonly" class="bp-date-value-start" data-date="today" />
<i class="fa fa-calendar"></i>
</div>
<span class="bp-label"> <?php _e('to', 'bizpanda') ?> </span>
<div class="bp-date-control bp-date-end" data-date="today">
<input size="16" type="text" readonly="readonly" class="bp-date-value-end" data-date="today" />
<i class="fa fa-calendar"></i>
</div>
</div>
<div class="bp-relative-date">
<span class="bp-label"> <?php _e('older than', 'bizpanda') ?> </span>
<input type="text" class="bp-date-value bp-date-value-start" value="1" />
<select class="bp-date-start-units">
<option value="seconds"><?php _e('Second(s)', 'bizpanda') ?></option>
<option value="minutes"><?php _e('Minutes(s)', 'bizpanda') ?></option>
<option value="hours"><?php _e('Hours(s)', 'bizpanda') ?></option>
<option value="days"><?php _e('Day(s)', 'bizpanda') ?></option>
<option value="weeks"><?php _e('Week(s)', 'bizpanda') ?></option>
<option value="months"><?php _e('Month(s)', 'bizpanda') ?></option>
<option value="years"><?php _e('Year(s)', 'bizpanda') ?></option>
</select>
<span class="bp-label"> <?php _e(', younger than', 'bizpanda') ?> </span>
<input type="text" class="bp-date-value bp-date-value-end" value="2" />
<select class="bp-date-end-units">
<option value="seconds"><?php _e('Second(s)', 'bizpanda') ?></option>
<option value="minutes"><?php _e('Minutes(s)', 'bizpanda') ?></option>
<option value="hours"><?php _e('Hours(s)', 'bizpanda') ?></option>
<option value="days"><?php _e('Day(s)', 'bizpanda') ?></option>
<option value="weeks"><?php _e('Week(s)', 'bizpanda') ?></option>
<option value="months"><?php _e('Month(s)', 'bizpanda') ?></option>
<option value="years"><?php _e('Year(s)', 'bizpanda') ?></option>
</select>
</div>
</div>
<div class="bp-solo-date">
<div class="bp-absolute-date">
<div class="bp-date-control" data-date="today">
<input size="16" type="text" class="bp-date-value" readonly="readonly" data-date="today" />
<i class="fa fa-calendar"></i>
</div>
</div>
<div class="bp-relative-date">
<input type="text" class="bp-date-value" value="1" />
<select class="bp-date-value-units">
<option value="seconds"><?php _e('Second(s)', 'bizpanda') ?></option>
<option value="minutes"><?php _e('Minutes(s)', 'bizpanda') ?></option>
<option value="hours"><?php _e('Hours(s)', 'bizpanda') ?></option>
<option value="days"><?php _e('Day(s)', 'bizpanda') ?></option>
<option value="weeks"><?php _e('Week(s)', 'bizpanda') ?></option>
<option value="months"><?php _e('Month(s)', 'bizpanda') ?></option>
<option value="years"><?php _e('Year(s)', 'bizpanda') ?></option>
</select>
</div>
</div>
</div>
<div class="bp-switcher">
<label><input type="radio" checked="checked" value="relative" /> <span><?php _e('relative', 'bizpanda') ?></span></label>
<label><input type="radio" value="absolute" /> </span><?php _e('absolute', 'bizpanda') ?></span></label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default bp-add-filter bp-btn-left"><?php _e('+ Add Filter', 'bizpanda') ?></button>
<button type="button" class="btn btn-default bp-cancel" data-dismiss="modal"><?php _e('Cancel', 'bizpanda') ?></button>
<button type="button" class="btn btn-primary bp-save"><?php _e('Save', 'bizpanda') ?></button>
</div>
</div>
</div>
</div>
</div>
<?php
}
/**
* Saves some extra options.
*/
public function onSavingForm( $post_id) {
parent::onSavingForm( $post_id );
// saves delay lock options
$delay = isset( $_POST[$this->scope . '_lock_delay'] );
$interval = isset( $_POST[$this->scope . '_lock_delay_interval'] )
? intval( $_POST[$this->scope . '_lock_delay_interval'] )
: 0;
if ( $interval < 0 ) $interval = 0;
$units = isset( $_POST[$this->scope . '_lock_delay_interval_units'] )
? $_POST[$this->scope . '_lock_delay_interval_units']
: null;
if ( !$units || !in_array($units, array('days', 'hours', 'minutes') )) {
$units = 'days';
}
if ( !$interval ) $_POST[$this->scope . '_lock_delay'] = null;
if ( !$delay ) {
$interval = 0;
$units = 'days';
}
$intervalInMinutes = $interval;
if ( $units == 'days' ) $intervalInMinutes = 24 * 60 * $interval;
if ( $units == 'hours' ) $intervalInMinutes = 60 * $interval;
$this->provider->setValue('lock_delay_interval_in_seconds', $intervalInMinutes * 60 );
$this->provider->setValue('lock_delay_interval', $interval);
$this->provider->setValue('lock_delay_interval_units', $units);
// saves relock options
$delay = isset( $_POST[$this->scope . '_relock'] );
$interval = isset( $_POST[$this->scope . '_relock_interval'] )
? intval( $_POST[$this->scope . '_relock_interval'] )
: 0;
if ( $interval < 0 ) $interval = 0;
$units = isset( $_POST[$this->scope . '_relock_interval_units'] )
? $_POST[$this->scope . '_relock_interval_units']
: null;
if ( !$units || !in_array($units, array('days', 'hours', 'minutes') )) {
$units = 'days';
}
if ( !$interval ) $_POST[$this->scope . '_relock'] = null;
if ( !$delay ) {
$interval = 0;
$units = 'days';
}
$intervalInMinutes = $interval;
if ( $units == 'days' ) $intervalInMinutes = 24 * 60 * $interval;
if ( $units == 'hours' ) $intervalInMinutes = 60 * $interval;
$this->provider->setValue('relock_interval_in_seconds', $intervalInMinutes * 60 );
$this->provider->setValue('relock_interval', $interval);
$this->provider->setValue('relock_interval_units', $units);
do_action('onp_sl_visability_options_on_save', $this);
}
}
global $bizpanda;
FactoryMetaboxes321::register('OPanda_VisabilityOptionsMetaBox', $bizpanda);