| 1 |
<?php |
| 2 |
/** |
| 3 |
* Ebook Store - Integrations settings tab. |
| 4 |
* |
| 5 |
* Rendered inside <div class="ebook-settings-panel">, so this file emits |
| 6 |
* <section> blocks only: no table rows, no cells. |
| 7 |
* |
| 8 |
* PHP 7.4 compatible. |
| 9 |
* |
| 10 |
* @package EbookStore |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
settings_fields( 'ebook-settings-group-integrations' ); |
| 18 |
do_settings_sections( 'ebook-settings-group-integrations' ); |
| 19 |
|
| 20 |
/* |
| 21 |
* Saved values. Every one of these options stores '1' when the switch is on and |
| 22 |
* an empty string when it is off, so a missing option is simply "off". |
| 23 |
*/ |
| 24 |
$customer_form_enabled = (string) get_option( 'formEnabled', '' ); |
| 25 |
$wpforms_override_enabled = (string) get_option( 'ebook_store_wpforms_default_form_force', '' ); |
| 26 |
$kindle_delivery_enabled = (string) get_option( 'kindleDelivery', '' ); |
| 27 |
$silent_registration_enabled = (string) get_option( 'ebook_store_silent_registration', '' ); |
| 28 |
$affiliate_integration_enabled = (string) get_option( 'ebook_store_wp_affiliate_integration', '' ); |
| 29 |
$disable_autorefresh = (string) get_option( 'ebook_store_no_autorefresh', '' ); |
| 30 |
$disable_cover_purchase = (string) get_option( 'ebook_store_disable_cover_buy_now', '' ); |
| 31 |
$hide_buy_now = (string) get_option( 'ebook_store_hide_buy_now', '' ); |
| 32 |
$disable_viewerjs_previews = (string) get_option( 'ebook_store_no_viewerjs_previews', '' ); |
| 33 |
|
| 34 |
$templates_url = ebook_store_get_settings_tab_url( 'Templates' ); |
| 35 |
$templates_link = '<a href="' . esc_url( $templates_url ) . '">' . esc_html__( 'Templates tab', 'ebook-store' ) . '</a>'; |
| 36 |
|
| 37 |
ebook_store_render_hero( |
| 38 |
array( |
| 39 |
'eyebrow' => __( 'Integrations', 'ebook-store' ), |
| 40 |
'title' => __( 'Connect Ebook Store to the rest of your selling workflow.', 'ebook-store' ), |
| 41 |
'intro' => __( 'Decide what buyers are asked for at checkout, how their files reach them, and which other plugins the store should talk to. Each switch explains exactly what happens when you turn it on.', 'ebook-store' ), |
| 42 |
'aside' => function () use ( $customer_form_enabled, $silent_registration_enabled, $affiliate_integration_enabled, $kindle_delivery_enabled, $templates_url ) { |
| 43 |
?> |
| 44 |
<aside class="ebook-settings-status-card"> |
| 45 |
<h4><?php echo esc_html__( 'What is switched on right now', 'ebook-store' ); ?></h4> |
| 46 |
<ul class="ebook-settings-status-list"> |
| 47 |
<?php |
| 48 |
ebook_store_status_row( |
| 49 |
__( 'Customer information form', 'ebook-store' ), |
| 50 |
$customer_form_enabled === '1' ? 'ok' : 'muted', |
| 51 |
$customer_form_enabled === '1' |
| 52 |
? __( 'Buyers fill in a short form before they get their files.', 'ebook-store' ) |
| 53 |
: __( 'Buyers go straight to payment without extra questions.', 'ebook-store' ), |
| 54 |
$customer_form_enabled === '1' |
| 55 |
? array( |
| 56 |
'label' => __( 'Edit the form', 'ebook-store' ), |
| 57 |
'url' => $templates_url, |
| 58 |
) |
| 59 |
: array() |
| 60 |
); |
| 61 |
|
| 62 |
ebook_store_status_row( |
| 63 |
__( 'Kindle email delivery', 'ebook-store' ), |
| 64 |
$kindle_delivery_enabled === '1' ? ( $customer_form_enabled === '1' ? 'ok' : 'warn' ) : 'muted', |
| 65 |
$kindle_delivery_enabled === '1' |
| 66 |
? ( $customer_form_enabled === '1' |
| 67 |
? __( 'Files are also sent to the Kindle address the buyer types in.', 'ebook-store' ) |
| 68 |
: __( 'Switched on, but nothing will be sent: there is no form to collect the Kindle address.', 'ebook-store' ) ) |
| 69 |
: __( 'Files are only sent to the normal email address.', 'ebook-store' ) |
| 70 |
); |
| 71 |
|
| 72 |
ebook_store_status_row( |
| 73 |
__( 'Customer accounts after purchase', 'ebook-store' ), |
| 74 |
$silent_registration_enabled === '1' ? 'ok' : 'muted', |
| 75 |
$silent_registration_enabled === '1' |
| 76 |
? __( 'An account is created automatically so buyers can download again later.', 'ebook-store' ) |
| 77 |
: __( 'No account is created. Buyers rely on their download links and emails.', 'ebook-store' ) |
| 78 |
); |
| 79 |
|
| 80 |
ebook_store_status_row( |
| 81 |
__( 'Affiliate tracking', 'ebook-store' ), |
| 82 |
$affiliate_integration_enabled === '1' ? 'ok' : 'muted', |
| 83 |
$affiliate_integration_enabled === '1' |
| 84 |
? __( 'Sales are reported to WP Affiliates Manager.', 'ebook-store' ) |
| 85 |
: __( 'Sales are not reported to any affiliate plugin.', 'ebook-store' ) |
| 86 |
); |
| 87 |
?> |
| 88 |
</ul> |
| 89 |
</aside> |
| 90 |
<?php |
| 91 |
}, |
| 92 |
) |
| 93 |
); |
| 94 |
|
| 95 |
ebook_store_pro_banner( __( 'Integrations', 'ebook-store' ) ); |
| 96 |
|
| 97 |
/* --------------------------------------------------------------------------- |
| 98 |
* Customer journey. |
| 99 |
* ------------------------------------------------------------------------ */ |
| 100 |
ebook_store_section_open( |
| 101 |
array( |
| 102 |
'eyebrow' => __( 'Customer journey', 'ebook-store' ), |
| 103 |
'title' => __( 'What happens between payment and download', 'ebook-store' ), |
| 104 |
'intro' => __( 'Ask buyers for extra details, send files to a Kindle, or create an account for them so they can come back for their downloads.', 'ebook-store' ), |
| 105 |
'id' => 'ebook-integrations-customer-journey', |
| 106 |
'pro' => true, |
| 107 |
) |
| 108 |
); |
| 109 |
|
| 110 |
ebook_store_toggle_grid_open(); |
| 111 |
|
| 112 |
ebook_store_toggle( |
| 113 |
array( |
| 114 |
'name' => 'formEnabled', |
| 115 |
'title' => __( 'Ask buyers to fill in a form', 'ebook-store' ), |
| 116 |
'description' => __( 'Turn this on to show a short form at checkout, for example to collect a name, a company or a delivery address. Leave it off and buyers go straight to payment. Keep the form short: every extra question loses a few sales.', 'ebook-store' ), |
| 117 |
'checked' => $customer_form_enabled, |
| 118 |
'pro' => true, |
| 119 |
) |
| 120 |
); |
| 121 |
|
| 122 |
ebook_store_toggle( |
| 123 |
array( |
| 124 |
'name' => 'ebook_store_silent_registration', |
| 125 |
'title' => __( 'Create a customer account after each purchase', 'ebook-store' ), |
| 126 |
'description' => __( 'Turn this on to create a WordPress account for the buyer and attach the order to it, so they can sign in later and download the book again. Leave it off if you do not want strangers to have accounts on your site.', 'ebook-store' ), |
| 127 |
'checked' => $silent_registration_enabled, |
| 128 |
'pro' => true, |
| 129 |
) |
| 130 |
); |
| 131 |
|
| 132 |
ebook_store_toggle_grid_close(); |
| 133 |
|
| 134 |
ebook_store_callout( |
| 135 |
sprintf( |
| 136 |
/* translators: %s: link to the Templates settings tab. */ |
| 137 |
__( 'The questions on the checkout form are part of the page templates. Add, remove or rename fields on the %s.', 'ebook-store' ), |
| 138 |
$templates_link |
| 139 |
), |
| 140 |
'info', |
| 141 |
__( 'Where to edit the form:', 'ebook-store' ) |
| 142 |
); |
| 143 |
|
| 144 |
ebook_store_advanced_open(); |
| 145 |
|
| 146 |
ebook_store_toggle_grid_open(); |
| 147 |
|
| 148 |
ebook_store_toggle( |
| 149 |
array( |
| 150 |
'name' => 'ebook_store_wpforms_default_form_force', |
| 151 |
'title' => __( 'Use a WPForms form instead of the built-in one', 'ebook-store' ), |
| 152 |
'description' => __( 'Turn this on only if you already build your forms with the WPForms plugin and want it to handle checkout questions. WPForms must be installed and active, otherwise buyers will see no form at all.', 'ebook-store' ), |
| 153 |
'checked' => $wpforms_override_enabled, |
| 154 |
'pro' => true, |
| 155 |
) |
| 156 |
); |
| 157 |
|
| 158 |
ebook_store_toggle( |
| 159 |
array( |
| 160 |
'name' => 'kindleDelivery', |
| 161 |
'title' => __( 'Also send the file to the buyer’s Kindle', 'ebook-store' ), |
| 162 |
'description' => __( 'Turn this on to email compatible files to the Send-to-Kindle address the buyer types in. The address must end in @kindle.com, and the buyer must have your sending address approved in their Amazon account, or Amazon will silently drop the email.', 'ebook-store' ), |
| 163 |
'checked' => $kindle_delivery_enabled, |
| 164 |
'pro' => true, |
| 165 |
) |
| 166 |
); |
| 167 |
|
| 168 |
ebook_store_toggle_grid_close(); |
| 169 |
|
| 170 |
ebook_store_callout( |
| 171 |
sprintf( |
| 172 |
/* translators: %s: link to the Templates settings tab. */ |
| 173 |
__( 'Kindle delivery only works when the checkout form contains a field named <code>kindle_email</code>. Open the %s and check that the field is there before you rely on it.', 'ebook-store' ), |
| 174 |
$templates_link |
| 175 |
), |
| 176 |
'warning', |
| 177 |
__( 'Kindle delivery needs one extra field:', 'ebook-store' ) |
| 178 |
); |
| 179 |
|
| 180 |
ebook_store_advanced_close(); |
| 181 |
|
| 182 |
ebook_store_grid_open( 2 ); |
| 183 |
?> |
| 184 |
<div class="ebook-settings-aside-card"> |
| 185 |
<h4><?php echo esc_html__( 'Before you turn the form on', 'ebook-store' ); ?></h4> |
| 186 |
<ul class="ebook-settings-checklist"> |
| 187 |
<li><?php echo esc_html__( 'Only ask for details you really use. Two or three fields is usually plenty.', 'ebook-store' ); ?></li> |
| 188 |
<li><?php echo esc_html__( 'Buy one of your own books as a test to see the form exactly as a customer does.', 'ebook-store' ); ?></li> |
| 189 |
<li><?php echo esc_html__( 'If you already collect the same details in WPForms, use the WPForms option instead of maintaining two forms.', 'ebook-store' ); ?></li> |
| 190 |
</ul> |
| 191 |
</div> |
| 192 |
|
| 193 |
<div class="ebook-settings-aside-card"> |
| 194 |
<h4><?php echo esc_html__( 'Let buyers read in the browser', 'ebook-store' ); ?></h4> |
| 195 |
<?php |
| 196 |
ebook_store_copy_box( |
| 197 |
'%%pdf_reader%%', |
| 198 |
__( 'Thank-you page placeholder', 'ebook-store' ), |
| 199 |
sprintf( |
| 200 |
/* translators: %s: link to the Templates settings tab. */ |
| 201 |
__( 'Paste this placeholder into your thank-you page content on the %s. It is replaced with the built-in reader when the page is shown, so buyers can read the book without downloading it.', 'ebook-store' ), |
| 202 |
$templates_link |
| 203 |
) |
| 204 |
); |
| 205 |
?> |
| 206 |
</div> |
| 207 |
<?php |
| 208 |
ebook_store_grid_close(); |
| 209 |
|
| 210 |
ebook_store_section_close(); |
| 211 |
|
| 212 |
/* --------------------------------------------------------------------------- |
| 213 |
* Third-party plugins. |
| 214 |
* ------------------------------------------------------------------------ */ |
| 215 |
ebook_store_section_open( |
| 216 |
array( |
| 217 |
'eyebrow' => __( 'Other plugins', 'ebook-store' ), |
| 218 |
'title' => __( 'Pay partners for the sales they bring you', 'ebook-store' ), |
| 219 |
'intro' => __( 'If other people promote your books for a commission, the store can report each sale to your affiliate plugin.', 'ebook-store' ), |
| 220 |
'id' => 'ebook-integrations-ecosystem', |
| 221 |
'pro' => true, |
| 222 |
) |
| 223 |
); |
| 224 |
|
| 225 |
ebook_store_toggle_grid_open(); |
| 226 |
|
| 227 |
ebook_store_toggle( |
| 228 |
array( |
| 229 |
'name' => 'ebook_store_wp_affiliate_integration', |
| 230 |
'title' => __( 'Report sales to WP Affiliates Manager', 'ebook-store' ), |
| 231 |
'description' => __( 'Turn this on to record which affiliate referred each ebook sale, so commissions are calculated for you. The WP Affiliates Manager plugin must be installed and active, otherwise nothing is recorded.', 'ebook-store' ), |
| 232 |
'checked' => $affiliate_integration_enabled, |
| 233 |
'pro' => true, |
| 234 |
) |
| 235 |
); |
| 236 |
|
| 237 |
ebook_store_toggle_grid_close(); |
| 238 |
|
| 239 |
ebook_store_callout( |
| 240 |
sprintf( |
| 241 |
/* translators: %s: link to the WP Affiliates Manager plugin page. */ |
| 242 |
__( 'This works with %s, a free plugin from the WordPress plugin directory.', 'ebook-store' ), |
| 243 |
'<a href="https://wordpress.org/plugins/affiliates-manager/" target="_blank" rel="noopener noreferrer">' . esc_html__( 'WP Affiliates Manager', 'ebook-store' ) . '</a>' |
| 244 |
), |
| 245 |
'soft', |
| 246 |
__( 'Compatible plugin:', 'ebook-store' ) |
| 247 |
); |
| 248 |
|
| 249 |
ebook_store_section_close(); |
| 250 |
|
| 251 |
/* --------------------------------------------------------------------------- |
| 252 |
* Negative-polarity switches, kept together so "on means off" is at least |
| 253 |
* consistent within one section. |
| 254 |
* ------------------------------------------------------------------------ */ |
| 255 |
ebook_store_advanced_open( __( 'Advanced: switches that remove features', 'ebook-store' ) ); |
| 256 |
|
| 257 |
ebook_store_section_open( |
| 258 |
array( |
| 259 |
'eyebrow' => __( 'Turn features off', 'ebook-store' ), |
| 260 |
'title' => __( 'Switches that remove something from your shop', 'ebook-store' ), |
| 261 |
'intro' => __( 'Everything in this section works the other way round: turning a switch ON removes or stops a feature. Use these when the store gets in the way of another plugin, or when a file will not display properly.', 'ebook-store' ), |
| 262 |
'id' => 'ebook-integrations-turn-off', |
| 263 |
'pro' => true, |
| 264 |
) |
| 265 |
); |
| 266 |
|
| 267 |
ebook_store_callout( |
| 268 |
__( 'These four switches are worded as removals on purpose. Leave them all off unless you have a specific problem to solve.', 'ebook-store' ), |
| 269 |
'warning', |
| 270 |
__( 'Careful:', 'ebook-store' ) |
| 271 |
); |
| 272 |
|
| 273 |
ebook_store_toggle_grid_open(); |
| 274 |
|
| 275 |
ebook_store_toggle( |
| 276 |
array( |
| 277 |
'name' => 'ebook_store_no_autorefresh', |
| 278 |
'title' => __( 'On: stop the download page refreshing by itself', 'ebook-store' ), |
| 279 |
'description' => __( 'While a protected copy of a book is being prepared, the download page normally refreshes until the file is ready. Turn this on to show a button the buyer presses instead. Useful for very large books on slow hosting, where the repeated refreshing looks broken.', 'ebook-store' ), |
| 280 |
'checked' => $disable_autorefresh, |
| 281 |
'pro' => true, |
| 282 |
) |
| 283 |
); |
| 284 |
|
| 285 |
ebook_store_toggle( |
| 286 |
array( |
| 287 |
'name' => 'ebook_store_disable_cover_buy_now', |
| 288 |
'title' => __( 'On: clicking a book cover no longer starts a purchase', 'ebook-store' ), |
| 289 |
'description' => __( 'Normally the cover image is itself a buy link. Turn this on to make the cover just a picture, so buyers must use your own button or the WooCommerce cart instead.', 'ebook-store' ), |
| 290 |
'checked' => $disable_cover_purchase, |
| 291 |
'pro' => true, |
| 292 |
) |
| 293 |
); |
| 294 |
|
| 295 |
ebook_store_toggle( |
| 296 |
array( |
| 297 |
'name' => 'ebook_store_hide_buy_now', |
| 298 |
'title' => __( 'On: hide the built-in “Buy Now” button', 'ebook-store' ), |
| 299 |
'description' => __( 'Turn this on when you sell through the WooCommerce cart and checkout and do not want a second, separate buy button on the page. Make sure your WooCommerce products are set up first, or visitors will have no way left to buy.', 'ebook-store' ), |
| 300 |
'checked' => $hide_buy_now, |
| 301 |
'pro' => true, |
| 302 |
) |
| 303 |
); |
| 304 |
|
| 305 |
ebook_store_toggle( |
| 306 |
array( |
| 307 |
'name' => 'ebook_store_no_viewerjs_previews', |
| 308 |
'title' => __( 'On: stop showing previews inside the page', 'ebook-store' ), |
| 309 |
'description' => __( 'Previews normally open in a reader built into the page. Turn this on to link straight to the preview file instead. Try it if your preview files show blank, or if links inside them do not work in the built-in reader.', 'ebook-store' ), |
| 310 |
'checked' => $disable_viewerjs_previews, |
| 311 |
'pro' => true, |
| 312 |
) |
| 313 |
); |
| 314 |
|
| 315 |
ebook_store_toggle_grid_close(); |
| 316 |
|
| 317 |
ebook_store_callout( |
| 318 |
sprintf( |
| 319 |
/* translators: %s: link to the WooCommerce settings tab. */ |
| 320 |
__( 'The last three switches are mainly for shops that sell through WooCommerce. Check that the store is connected to WooCommerce on the %s before you hide the built-in buttons.', 'ebook-store' ), |
| 321 |
'<a href="' . esc_url( ebook_store_get_settings_tab_url( 'WooCommerce' ) ) . '">' . esc_html__( 'WooCommerce tab', 'ebook-store' ) . '</a>' |
| 322 |
), |
| 323 |
'info', |
| 324 |
__( 'Selling through WooCommerce?', 'ebook-store' ) |
| 325 |
); |
| 326 |
|
| 327 |
ebook_store_section_close(); |
| 328 |
|
| 329 |
ebook_store_advanced_close(); |
| 330 |
|