esc_html__( 'EDD Sidebar', 'oceanwp' ),
'id' => 'edd_sidebar',
'before_widget' => '
',
'before_title' => '',
)
);
}
/**
* Display EDD sidebar.
*
* @since 1.0.0
*/
public static function display_edd_sidebar( $sidebar ) {
// Alter sidebar display to show edd_sidebar where needed
if ( get_theme_mod( 'ocean_edd_custom_sidebar', true )
&& is_active_sidebar( 'edd_sidebar' )
&& oceanwp_is_edd_page() ) {
$sidebar = 'edd_sidebar';
}
// Return correct sidebar
return $sidebar;
}
/**
* Tweaks the post layouts for EDD archives and single product posts.
*
* @since 1.0.0
*/
public static function layouts( $class ) {
if ( is_post_type_archive( 'download' ) ||
is_tax( 'download_category' ) ||
is_tax( 'download_tag' ) ) {
$class = get_theme_mod( 'ocean_edd_archive_layout', 'left-sidebar' );
} elseif ( is_singular( 'download' ) ) {
$class = get_theme_mod( 'ocean_edd_download_layout', 'left-sidebar' );
}
return $class;
}
/**
* Set correct both sidebars layout style.
*
* @since 1.4.0
*/
public static function bs_class( $class ) {
if ( is_post_type_archive( 'download' ) ||
is_tax( 'download_category' ) ||
is_tax( 'download_tag' ) ) {
$class = get_theme_mod( 'ocean_edd_archive_both_sidebars_style', 'scs-style' );
} elseif ( is_singular( 'download' ) ) {
$class = get_theme_mod( 'ocean_edd_product_both_sidebars_style', 'scs-style' );
}
return $class;
}
/**
* Set correct mobile sidebar order.
*
* @since 1.6
*/
public static function sidebar_order( $order ) {
if ( is_post_type_archive( 'download' ) ||
is_tax( 'download_category' ) ||
is_tax( 'download_tag' ) ) {
$order = get_theme_mod( 'ocean_edd_archive_sidebar_order', 'content-sidebar' );
} elseif ( is_singular( 'download' ) ) {
$order = get_theme_mod( 'ocean_edd_download_sidebar_order', 'content-sidebar' );
}
return $order;
}
/**
* Add Custom EDD scripts.
*
* @since 1.0.0
*/
public static function add_custom_scripts() {
wp_enqueue_style( 'oceanwp-edd', OCEANWP_CSS_DIR_URI . 'edd/edd.min.css', array(), OCEANWP_THEME_VERSION, 'all' );
wp_enqueue_script( 'oceanwp-edd-ajax-cart', OCEANWP_JS_DIR_URI . 'wp-plugins/easy-digital-downloads/edd-ajax-cart.min.js', array(), OCEANWP_THEME_VERSION, true );
// If display cart when product added.
if ( 'yes' === get_theme_mod( 'ocean_edd_display_cart_download_added', 'no' ) ) {
wp_enqueue_script( 'oceanwp-edd-display-cart', OCEANWP_JS_DIR_URI . 'wp-plugins/easy-digital-downloads/edd-display-cart.min.js', array(), OCEANWP_THEME_VERSION, true );
}
}
/**
* Add cart overlay.
*
* @since 1.5.0
*/
public static function cart_overlay() { ?>
array( 'top' ),
'.simple-style.eddmenucart .edd-cart-quantity.count:after',
'.edd_downloads_list .button:hover',
'.bag-style:hover .eddmenucart-cart-icon .eddmenucart-container:after',
'.show-cart .eddmenucart-cart-icon .eddmenucart-container:after',
'.bag-style:hover .eddmenucart-cart-icon .eddmenucart-container',
'.show-cart .eddmenucart-cart-icon .eddmenucart-container',
'.edd_downloads_list .button:hover .edd-loading',
),
$borders
);
}
/**
* Adds background accents for EDD styles.
*
* @since 1.0.0
*/
public static function primary_backgrounds( $backgrounds ) {
return array_merge(
array(
'.content-area ul.edd-cart li .edd-cart-item-price',
'.widget-area ul.edd-cart li .edd-cart-item-price',
'.simple-style.eddmenucart .edd-cart-quantity.count',
'.bag-style:hover .eddmenucart-cart-icon .eddmenucart-container',
'.show-cart .eddmenucart-cart-icon .eddmenucart-container',
'.content-area ul.edd-cart li.edd_checkout a',
'.widget-area ul.edd-cart li.edd_checkout a',
'.current-shop-items-dropdown .widget_edd_cart_widget .edd_checkout a',
),
$backgrounds
);
}
/**
* Adds background hover accents for EDD styles.
*
* @since 1.0.0
*/
public static function hover_primary_backgrounds( $hover ) {
return array_merge(
array(
'.content-area ul.edd-cart li.edd_checkout a:hover',
'.widget-area ul.edd-cart li.edd_checkout a:hover',
'.current-shop-items-dropdown .widget_edd_cart_widget .edd_checkout a:hover',
),
$hover
);
}
/**
* Adds border color elements for EDD styles.
*
* @since 1.0.0
*/
public static function border_color_elements( $elements ) {
return array_merge(
array(
'#edd_checkout_user_info',
'#edd_checkout_form_wrap legend',
'#edd_checkout_form_wrap #edd-discount-code-wrap',
'#edd_checkout_form_wrap #edd_final_total_wrap',
'#edd_checkout_form_wrap #edd_show_discount',
'#edd_checkout_form_wrap fieldset',
'.edd-table th, .edd-table td',
),
$elements
);
}
/**
* Adds cart icon to menu
*
* @since 1.0.0
*/
public static function menu_cart_icon( $items, $args ) {
// Return items if is in the Elementor edit mode, to avoid error
if ( OCEANWP_ELEMENTOR_ACTIVE
&& \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
return $items;
}
// Only used for the main menu
if ( 'main_menu' != $args->theme_location ) {
return $items;
}
// Get style
$style = oceanwp_edd_menu_cart_style();
$header_style = oceanwp_header_style();
// Return items if no style
if ( ! $style ) {
return $items;
}
// Return items if "hide if empty cart" is checked
if ( true == get_theme_mod( 'ocean_edd_menu_icon_hide_if_empty', false )
&& ! count( is_array( edd_get_cart_quantity() ) ? edd_get_cart_quantity() : array() ) > 0 ) {
return $items;
}
// Add cart link to menu items
if ( 'full_screen' == $header_style ) {
$items .= '' . esc_html__( 'Your cart', 'oceanwp' ) . '';
} else {
$items .= self::get_cart_icon();
}
// Return menu items
return $items;
}
/**
* Add cart icon
*
* @since 1.5.0
*/
public static function get_cart_icon() {
// Style
$style = oceanwp_edd_menu_cart_style();
$header_style = oceanwp_header_style();
$cart_style = get_theme_mod( 'ocean_edd_cart_dropdown_style', 'compact' );
// Toggle class
$toggle_class = 'toggle-cart-widget';
// Define classes to add to li element
$classes = array( 'edd-menu-icon' );
// Add style class
$classes[] = 'eddmenucart-toggle-' . $style;
// If bag style
if ( 'yes' == get_theme_mod( 'ocean_edd_menu_bag_style', 'no' ) ) {
$classes[] = 'bag-style';
}
// Cart style
if ( 'compact' != $cart_style ) {
$classes[] = $cart_style;
}
// Prevent clicking on cart and checkout
if ( 'drop_down' == $style ) {
$classes[] = 'nav-no-click';
}
if ( true == get_theme_mod( 'ocean_edd_menu_icon_hide_if_empty', false )
&& ! edd_get_cart_quantity() > 0 ) {
$classes[] = 'edd-cart-empty';
}
// Add toggle class
else {
$classes[] = $toggle_class;
}
// Turn classes into string
$classes = implode( ' ', $classes );
ob_start();
?>
esc_html__( 'EDD Product Title', 'oceanwp' ),
'target' => '.edd_download_title, .widget_edd_product_details h4',
'defaults' => array(
'font-size' => '24',
'color' => '#333333',
'line-height' => '1.4',
'letter-spacing' => '0.6',
),
);
$settings['edd_product_price'] = array(
'label' => esc_html__( 'EDD Product Price', 'oceanwp' ),
'target' => '.edd_price, .edd_single_mode',
'defaults' => array(
'font-size' => '36',
'line-height' => '1',
'letter-spacing' => '0',
),
);
$settings['edd_product_add_to_cart'] = array(
'label' => esc_html__( 'EDD Product Add To Cart', 'oceanwp' ),
'target' => '.edd_downloads_list .button, .edd-add-to-cart',
'exclude' => array( 'font-color' ),
'defaults' => array(
'font-size' => '12',
'line-height' => '1.5',
'letter-spacing' => '1',
),
);
return $settings;
}
}
}
new OceanWP_EDD_Config();