Created
February 12, 2018 19:48
-
-
Save codeiscode-dev/c579f651285dbbdf39d89a552fa47a0b to your computer and use it in GitHub Desktop.
WPEP Content Library Integration Administration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class WPEP_Integration_Content_Library_Coordinator_Administration { | |
/** | |
* @var WPEP_Content_Library_Integration | |
*/ | |
protected $_controller; | |
public function init( $controller ) { | |
$this->_controller = $controller; | |
if( $this->_controller->meta_box_active ) | |
add_filter( 'wpep_meta_boxes', [ $this, 'entity_metaboxes' ] ); | |
} | |
public function entity_metaboxes( $meta_boxes ) { | |
$meta_boxes[ $this->_controller->slug . '-settings'] = [ | |
'id' => $this->_controller->prefix . '-settings', | |
'title' => __( $this->_controller->meta_box_title, $this->_controller->prefix . '_integration' ), | |
'pages' => $this->_controller->meta_box_pages, | |
'context' => 'side', | |
'priority' => 'low', | |
'show_names' => true, | |
'fields' => $this->get_metabox_fields() | |
]; | |
return $meta_boxes; | |
} | |
public function get_metabox_fields() { | |
$fields = []; | |
if( $this->_controller->primary_meta_field_key != '' ) | |
$fields[] = [ | |
'name' => __( $this->_controller->primary_meta_field_label, $this->_controller->prefix . '_integration' ), | |
'desc' => __( $this->_controller->primary_meta_field_desc, $this->_controller->prefix . '_integration' ), | |
'id' => $this->_controller->primary_meta_field_key, | |
'type' => 'multiple_select', | |
'values'=> $this->_controller->get_post_protection_entity_map() | |
]; | |
$fields[] = [ | |
'name' => __( 'Sell Link', $this->_controller->prefix . '_integration' ), | |
'desc' => __( 'By default the one from settings will be used.', $this->_controller->prefix . '_integration' ), | |
'id' => $this->_controller->prefix . $this->_controller->redirect_meta_field_suffix, | |
'type' => 'text', | |
'placeholder' => get_option( $this->_controller->options_prefix . '_sell_button_url', '' ) | |
]; | |
$fields[] = [ | |
'name' => __( 'Sell Text', $this->_controller->prefix . '_integration' ), | |
'desc' => __( 'By default the one from settings will be used.', $this->_controller->prefix . '_integration' ), | |
'id' => $this->_controller->prefix . $this->_controller->cta_meta_field_suffix, | |
'type' => 'text', | |
'placeholder' => get_option( $this->_controller->options_prefix . $this->_controller->cta_meta_field_suffix, $this->_controller->default_purchase_cta ) | |
]; | |
return $fields; | |
} | |
public function get_global_options_settings( $current_options = [] ) { | |
return $current_options + [ | |
'disable_up_sell_functionality' => [ | |
'name' => __( "Disable Up-Selling", $this->_controller->prefix . '_integration' ), | |
'type' => 'checkbox', | |
'value' => get_option( $this->_controller->options_prefix . '_disable_up_sell_functionality', 0 ), | |
], | |
'sell_button_url' => [ | |
'name' => __( "Default Redirect Link", $this->_controller->prefix . '_integration' ), | |
'type' => 'text', | |
'value' => get_option( $this->_controller->options_prefix . '_sell_button_url', '' ), | |
], | |
'sell_button_text' => [ | |
'name' => __( "Buy Now Button", $this->_controller->prefix . '_integration' ), | |
'type' => 'text', | |
'value' => get_option( $this->_controller->options_prefix . '_sell_button_text', $this->_controller->default_purchase_cta ), | |
], | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment