easy-digital-downloads.php
4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Plugin compatibility for easy-digital-downloads
* @since 0.7 (builder version)
* @link https://easydigitaldownloads.com
*/
class ET_Builder_Plugin_Compat_Easy_Digital_Downloads extends ET_Builder_Plugin_Compat_Base {
/**
* Constructor
*/
function __construct() {
$this->plugin_id = "easy-digital-downloads/easy-digital-downloads.php";
$this->init_hooks();
}
/**
* Hook methods to WordPress
* Note: once this issue is fixed in future version, run version_compare() to limit the scope of the hooked fix
* Latest plugin version: 2.6.17
* @return void
*/
function init_hooks() {
// Bail if there's no version found
if ( ! $this->get_plugin_version() ) {
return;
}
// Up to: latest theme version
if ( ! is_admin() ) {
add_filter( 'edd_purchase_link_defaults', array( $this, 'purchase_link_defaults' ) );
add_filter( 'shortcode_atts_purchase_link', array( $this, 'purchase_link_defaults' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'add_compatibility_scripts' ), 15 );
} else {
add_filter( 'edd_checkout_button_purchase', array( $this, 'modify_edd_checkout_button_purchase' ) );
}
}
/**
* Appended et_pb_button for various EDD button so it matches Divi styled button
* @param array initial link configuration
* @return array moodified link configuration
*/
function purchase_link_defaults ( $args ) {
if ( isset( $args['class'] ) ) {
$args['class'] = $args['class'] . ' et_pb_button';
}
return $args;
}
/**
* Addded et_pb_button class for checkout button which has no attribute filter
* @param string of HTML of the button
* @return string of modified HTML of the button
*/
function modify_edd_checkout_button_purchase( $button ) {
$button = str_replace( 'edd-submit', 'edd-submit et_pb_button', $button );
return $button;
}
/**
* Added additional styling & scripts for EDD on Divi
* @return void
*/
function add_compatibility_scripts() {
// Normalize UI for Divi Builder
if ( et_is_builder_plugin_active() ) {
wp_add_inline_style( 'et-builder-modules-style', "
.et_divi_builder #et_builder_outer_content .edd_download_inner {
padding: 0 8px 8px;
margin: 0 0 10px;
}
.et_divi_builder #et_builder_outer_content .edd_download_excerpt p {
margin-bottom: 25px;
}
.et_divi_builder #et_builder_outer_content .edd_purchase_submit_wrapper {
margin-top: 15px;
margin-bottom: 35px;
}
.et_divi_builder #et_builder_outer_content ul.edd-cart {
border: 1px solid #eee;
margin-top: 0.8em;
}
.et_divi_builder #et_builder_outer_content ul.edd-cart li {
padding: 0.8em 1.387em;
border-bottom: 1px solid #eee;
}
.et_divi_builder #et_builder_outer_content ul.edd-cart li:last-child {
border-bottom: none;
}
.et_divi_builder #et_builder_outer_content ul.edd-cart .edd-cart-item span {
padding: 0 3px;
}
.et_divi_builder #et_builder_outer_content ul.edd-cart .edd-cart-item a {
text-decoration: underline !important;
}
.et_divi_builder #et_builder_outer_content .edd_cart_item_image {
margin-right: 10px;
display: inline-block;
vertical-align: middle;
}
.et_divi_builder #et_builder_outer_content .edd-cart-meta.edd_subtotal,
.et_divi_builder #et_builder_outer_content .edd-cart-meta.edd_total {
background: #f9f9f9;
}
.et_divi_builder #et_builder_outer_content .cart_item.edd_checkout {
padding: 1.387em;
}
.et_divi_builder #et_builder_outer_content .et_pb_module a.edd_cart_remove_item_btn {
text-decoration: underline !important;
}
.et_divi_builder #et_builder_outer_content #edd_profile_editor_form .edd-select,
.et_divi_builder #et_builder_outer_content #edd_profile_editor_form .edd-input {
margin-bottom: 5px;
}
.et_divi_builder #et_builder_outer_content #edd_final_total_wrap {
margin-bottom: 20px;
}
.et_divi_builder #et_builder_outer_content .et_pb_module .et_pb_button {
border-bottom-style: solid;
border-bottom-width: 2px;
}
.et_divi_builder #et_builder_outer_content .et_pb_module input.et_pb_button:hover {
padding-right: 1em;
}
" );
}
// Re-styled button with Divi's button UI using javascript due to lack of filter
wp_add_inline_script( 'et-builder-modules-script', "
(function($){
$(document).ready( function(){
$('.cart_item.edd_checkout a, input[name=\"edd_register_submit\"], .edd_submit').addClass( 'et_pb_button' ).attr('style', 'padding-right: 1em;');
});
})(jQuery)
");
}
}
new ET_Builder_Plugin_Compat_Easy_Digital_Downloads;