* @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' : ''; ?>