forked from LearnPress/learnpress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
732 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { getCategories, setCategories } from '@wordpress/blocks'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
setCategories( [ | ||
...getCategories().filter( ( { slug } ) => slug !== 'learnpress' ), | ||
{ | ||
slug: 'learnpress', | ||
title: __( 'LearnPress', 'learnpress' ), | ||
}, | ||
] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
import './category'; | ||
|
||
import * as template from './template'; | ||
|
||
const registerBlock = ( block ) => { | ||
if ( ! block ) { | ||
return; | ||
} | ||
|
||
const { metadata, settings, name } = block; | ||
|
||
registerBlockType( name, { ...metadata, ...settings } ); | ||
}; | ||
|
||
/** | ||
* Function to register blocks. | ||
*/ | ||
export const registerLearnPressBlocks = () => { | ||
[ | ||
template, | ||
].forEach( registerBlock ); | ||
}; | ||
|
||
registerLearnPressBlocks(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"apiVersion": 2, | ||
"name": "learnpress/template", | ||
"category": "learnpress", | ||
"attributes": { | ||
"template": { | ||
"type": "string", | ||
"default": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
import { useBlockProps } from '@wordpress/block-editor'; | ||
import { Placeholder } from '@wordpress/components'; | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import { page } from '@wordpress/icons'; | ||
|
||
const TEMPLATES = { | ||
'single-course': { | ||
title: __( 'LearnPress Single Course Template', 'learnpress' ), | ||
placeholder: 'single-course', | ||
}, | ||
'archive-course': { | ||
title: __( 'LearnPress Course Archive Template', 'learnpress' ), | ||
placeholder: 'archive-course', | ||
}, | ||
}; | ||
|
||
export default function Edit( { attributes } ) { | ||
const blockProps = useBlockProps(); | ||
const templateTitle = TEMPLATES[ attributes.template ]?.title ?? attributes.template; | ||
|
||
return ( | ||
<div { ...blockProps }> | ||
<Placeholder | ||
icon={ page } | ||
label={ templateTitle } | ||
className="wp-block-learnpress-template__placeholder" | ||
> | ||
<div className="wp-block-learnpress-template__placeholder-inner"> | ||
{ sprintf( | ||
/* translators: %s is the template title */ | ||
__( | ||
'This is an editor placeholder for the %s. On your store this will be replaced by the template and display with your course image(s), title, price, etc. You can move this placeholder around and add further blocks around it to extend the template.', | ||
'learnpress' | ||
), | ||
templateTitle | ||
) } | ||
</div> | ||
</Placeholder> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
import { __ } from '@wordpress/i18n'; | ||
|
||
import edit from './edit'; | ||
|
||
import metadata from './block.json'; | ||
|
||
const { name } = metadata; | ||
|
||
const settings = { | ||
title: 'LearnPress Template', | ||
keywords: [ 'learnpress', 'template' ], | ||
description: __( 'Renders LearnPress PHP templates.', 'learnpress' ), | ||
icon: 'archive', | ||
edit, | ||
save: () => null, | ||
}; | ||
|
||
export { name, settings, metadata }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.learnpress.theme-twentytwentytwo { | ||
|
||
.wp-site-blocks { | ||
max-width: none; | ||
padding-right: 0; | ||
padding-left: 0; | ||
|
||
> .wp-block-group { | ||
max-width: none; | ||
margin-right: auto; | ||
margin-left: auto; | ||
} | ||
} | ||
|
||
.lp-archive-courses { | ||
max-width: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- wp:template-part {"slug":"header"} /--> | ||
<!-- wp:group {"layout":{"inherit":true}} --> | ||
<div class="wp-block-group"><!-- wp:learnpress/template {"template":"archive-course"} /--></div> | ||
<!-- /wp:group --> | ||
<!-- wp:template-part {"slug":"footer"} /--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!-- wp:template-part {"slug":"header"} /--> | ||
<!-- wp:group {"layout":{"inherit":true}} --> | ||
<div class="wp-block-group"><!-- wp:learnpress/template {"template":"single-course"} /--></div> | ||
<!-- /wp:group --> | ||
<!-- wp:template-part {"slug":"footer"} /--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.