2022-11-27 15:03:07 +00:00
< ? php
/**
* Plugin Name : Easy Digital Downloads - Blocks
* Description : Core blocks for Easy Digital Downloads .
* Requires at least : 5.8
* Requires PHP : 7.0
2023-06-28 12:45:44 +00:00
* Version : 2.0 . 7
2022-11-27 15:03:07 +00:00
* Author : Easy Digital Downloads
* License : GPL - 2.0 - or - later
* License URI : https :// www . gnu . org / licenses / gpl - 2.0 . html
* Text Domain : easy - digital - downloads
*
* @ package edd
*/
namespace EDD\Blocks ;
defined ( 'ABSPATH' ) || exit ;
// EDD core blocks are registered for WordPress 5.8 and higher, and EDD must be active.
if ( version_compare ( get_bloginfo ( 'version' ), '5.8' , '<' ) || ! function_exists ( 'EDD' ) ) {
return ;
}
add_action ( 'plugins_loaded' , __NAMESPACE__ . '\init_core_blocks' , 500 );
/**
* Initialize the blocks .
*
* @ since 2.0
* @ return void
*/
function init_core_blocks () {
if ( ! defined ( 'EDD_BLOCKS_DIR' ) ) {
define ( 'EDD_BLOCKS_DIR' , plugin_dir_path ( __FILE__ ) );
}
if ( ! defined ( 'EDD_BLOCKS_URL' ) ) {
define ( 'EDD_BLOCKS_URL' , plugin_dir_url ( __FILE__ ) );
}
$files = array (
'functions' ,
'styles' ,
'downloads/downloads' ,
'forms/forms' ,
'orders/orders' ,
'terms/terms' ,
'checkout/checkout' ,
);
foreach ( $files as $file ) {
require_once trailingslashit ( EDD_BLOCKS_DIR . 'includes' ) . $file . '.php' ;
}
if ( is_admin () ) {
$admin_files = array (
'functions' ,
'notices' ,
'recaptcha' ,
'scripts' ,
'settings' ,
);
foreach ( $admin_files as $file ) {
require_once trailingslashit ( EDD_BLOCKS_DIR . 'includes/admin' ) . $file . '.php' ;
}
}
2023-03-17 22:34:04 +00:00
if ( edd_is_pro () ) {
2023-06-05 11:21:17 +00:00
if ( file_exists ( EDD_BLOCKS_DIR . 'pro/pro.php' ) ) {
require_once EDD_BLOCKS_DIR . 'pro/pro.php' ;
Pro\init ();
2023-03-17 22:34:04 +00:00
}
}
2022-11-27 15:03:07 +00:00
}
add_filter ( 'edd_required_pages' , __NAMESPACE__ . '\update_core_required_pages' );
/**
* Update the EDD required pages array to include blocks .
* This is in the main plugin file so that it ' s available to the EDD installer .
*
* @ since 2.0
*/
function update_core_required_pages ( $pages ) {
2023-03-17 22:34:04 +00:00
$pages [ 'confirmation_page' ] = array (
2022-11-27 15:03:07 +00:00
'post_title' => __ ( 'Confirmation' , 'easy-digital-downloads' ),
'post_content' => '<!-- wp:paragraph --><p>' . __ ( 'Thank you for your purchase!' , 'easy-digital-downloads' ) . '</p><!-- /wp:paragraph --><!-- wp:edd/confirmation /-->' ,
);
2023-03-17 22:34:04 +00:00
$pages [ 'success_page' ] = array (
2022-11-27 15:03:07 +00:00
'post_title' => __ ( 'Receipt' , 'easy-digital-downloads' ),
'post_content' => '<!-- wp:edd/receipt /-->' ,
);
2023-03-17 22:34:04 +00:00
$pages [ 'purchase_history_page' ] = array (
2022-11-27 15:03:07 +00:00
'post_title' => __ ( 'Order History' , 'easy-digital-downloads' ),
'post_content' => '<!-- wp:edd/order-history /-->' ,
);
2023-03-17 22:34:04 +00:00
$pages [ 'purchase_page' ][ 'post_content' ] = '<!-- wp:edd/checkout /-->' ;
2022-11-27 15:03:07 +00:00
return $pages ;
}