.
*/
class BREBootstrapEcommerceSetup {
function __construct() {
add_action( 'admin_menu', array( &$this, 'admin_menu' ), 50 );
}
function admin_menu() {
$page = add_theme_page( __( 'Bootstrap eCommerce options', 'bre-bootstrap-ecommerce' ), __( 'Options', 'bre-bootstrap-ecommerce' ), 'edit_theme_options', 'bootstrap_ecommerce_settings', array( &$this, 'admin_page' ) );
add_action( "load-$page", array( &$this, 'admin_action' ) );
}
function admin_page() {
$bre_primary_menu = get_option( 'bre_primary_menu', '' );
$bre_primary_menu_transparent = get_option( 'bre_primary_menu_transparent', true );
$bre_secondary_menu = get_option( 'bre_secondary_menu', 'navbar-inverse' );
$bre_secondary_menu_transparent = get_option( 'bre_secondary_menu_transparent', false );
$bre_label_one = get_option( 'bre_label_one', __( 'Label one', 'bre-bootstrap-ecommerce' ) );
$bre_label_two = get_option( 'bre_label_two', __( 'Label two', 'bre-bootstrap-ecommerce' ) );
$bre_label_three = get_option( 'bre_label_three', __( 'Label three', 'bre-bootstrap-ecommerce' ) );
$bre_sidebar_style = get_option( 'bre_sidebar_style', false );
$bre_layout = get_option( 'bre_layout', 'content-sidebar' );
$bre_carousel_hide = get_option( 'bre_carousel_hide', false );
$bre_carousel_excerpt_length = get_option( 'bre_carousel_excerpt_length', 50 );
$bre_carousel_hide_more_details = get_option( 'bre_carousel_hide_more_details', false );
$bre_carousel_opacity = get_option( 'bre_carousel_opacity', 0.6 );
$bre_site_description_hide = get_option( 'bre_site_description_hide', false );
?>
update_file( 'bre_image_logo' );
} elseif ( isset( $_REQUEST['remove_bootstrap_logo'] ) ) {
$this->remove_file( 'bre_image_logo' );
}
update_option( 'bre_primary_menu', $_REQUEST['bre_primary_menu'] );
update_option( 'bre_primary_menu_transparent', isset( $_REQUEST['bre_primary_menu_transparent'] ) );
update_option( 'bre_secondary_menu', $_REQUEST['bre_secondary_menu'] );
update_option( 'bre_secondary_menu_transparent', isset( $_REQUEST['bre_secondary_menu_transparent'] ) );
update_option( 'bre_label_one', $_REQUEST['bre_label_one'] );
if ( function_exists( 'bre_register_string' ) ) bre_register_string( 'Bootstrap eCommerce', 'label one', $_REQUEST['bre_label_one'] );
update_option( 'bre_label_two', $_REQUEST['bre_label_two'] );
if ( function_exists( 'bre_register_string' ) ) bre_register_string( 'Bootstrap eCommerce', 'label two', $_REQUEST['bre_label_two'] );
update_option( 'bre_label_three', $_REQUEST['bre_label_three'] );
if ( function_exists( 'bre_register_string' ) ) bre_register_string( 'Bootstrap eCommerce', 'label three', $_REQUEST['bre_label_three'] );
update_option( 'bre_sidebar_style', isset( $_REQUEST['bre_sidebar_style'] ) );
update_option( 'bre_layout', $_REQUEST['bre_layout'] );
update_option( 'bre_carousel_hide', isset( $_REQUEST['bre_carousel_hide'] ) );
update_option( 'bre_carousel_opacity', (float)$_REQUEST['bre_carousel_opacity'] );
update_option( 'bre_carousel_excerpt_length', (float)$_REQUEST['bre_carousel_excerpt_length'] );
update_option( 'bre_carousel_hide_more_details', isset( $_REQUEST['bre_carousel_hide_more_details'] ) );
update_option( 'bre_site_description_hide', isset( $_REQUEST['bre_site_description_hide'] ) );
//3 ShortCuts
update_option( 'bre_hide_home_shortcuts', isset( $_POST['hide_home_shortcuts'] ) );
update_option( 'bre_url_a', $_POST['bre_url_a'] );
update_option( 'bre_url_b', $_POST['bre_url_b'] );
update_option( 'bre_url_c', $_POST['bre_url_c'] );
update_option( 'bre_label_a', $_POST['bre_label_a'] );
update_option( 'bre_label_b', $_POST['bre_label_b'] );
update_option( 'bre_label_c', $_POST['bre_label_c'] );
update_option( 'bre_description_a', $_POST['bre_description_a'] );
update_option( 'bre_description_b', $_POST['bre_description_b'] );
update_option( 'bre_description_c', $_POST['bre_description_c'] );
$this->update_file( 'bre_image_a' );
$this->update_file( 'bre_image_b' );
$this->update_file( 'bre_image_c' );
if ( isset( $_REQUEST['save-pagina_home-remove_image_a'] ) ) {
$this->remove_file( 'bre_image_a' );
} elseif ( isset( $_REQUEST['save-pagina_home-remove_image_b'] ) ) {
$this->remove_file( 'bre_image_b' );
} elseif ( isset( $_REQUEST['save-pagina_home-remove_image_c'] ) ) {
$this->remove_file( 'bre_image_c' );
}
$this->updated = true;
}
function update_file( $id ) {
if ( isset( $_FILES[$id] ) && $_FILES[$id]['name'] !== '' ) {
$this->remove_file( $id );
$file = $_FILES[$id];
if ( ! function_exists( 'wp_handle_upload' ) ) require_once( ABSPATH . 'wp-admin/includes/file.php' );
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $file, $upload_overrides );
update_option( $id, $movefile );
}
}
private function remove_file( $id ) {
$path_to_delete = get_option( $id, false );
if ( $path_to_delete !== false ) unlink( $path_to_delete['file'] );
delete_option( $id );
}
}
new BREBootstrapEcommerceSetup();
add_shortcode( '3boxes', 'bre_get_the_three_boxes' );
function bre_get_the_three_boxes() {
return bre_the_three_boxes( false );
}
function bre_the_three_boxes( $echo = true ) {
ob_start(); ?>