Skip to content

Commit

Permalink
first pass at plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pattyok committed Jan 30, 2023
1 parent df0e72a commit 1e60434
Show file tree
Hide file tree
Showing 33 changed files with 889 additions and 595 deletions.
Binary file added .DS_Store
Binary file not shown.
65 changes: 0 additions & 65 deletions build/custom-links/block.json

This file was deleted.

1 change: 0 additions & 1 deletion build/custom-links/index.js

This file was deleted.

1 change: 0 additions & 1 deletion build/custom-links/style-index.css

This file was deleted.

71 changes: 71 additions & 0 deletions build/yt-embed/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "carkeek-blocks/youtube-embed",
"version": "0.1.0",
"title": "Youtube Embeds",
"category": "widgets",
"icon": "smiley",
"description": "Display a List of Youtube Videos.",
"supports": {
"html": false,
"anchor": true
},
"keywords": [
"youtube",
"carousel",
"videos"
],
"textdomain": "carkeek-blocks",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css",
"render": "file:./render.php",
"viewScript": "file:./script.js",
"attributes": {
"taxTermsSelected": {
"type": "string",
"default": ""
},
"taxQueryType": {
"type": "string",
"default": "AND"
},
"displayAs": {
"type": "string",
"default": "grid"
},
"sortBy": {
"type": "string",
"default": "title"
},
"order": {
"type": "string",
"default": "ASC"
},
"columns": {
"type": "number",
"default": 3
},
"columnsMobile": {
"type": "number",
"default": 1
},
"columnsTablet": {
"type": "number",
"default": 3
},
"autoPlay": {
"type": "boolean",
"default": true
},
"autoPlaySpeed": {
"type": "number",
"default": 3000
},
"context": {
"type": "string",
"default": "view"
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'f08c1cb2fc39ace359c9');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '3d7c8ccd42b1c4ace6e5');
1 change: 1 addition & 0 deletions build/yt-embed/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build/yt-embed/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions build/yt-embed/render.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/** Layout template for the youtube embeds */

$number = 'carousel' === $attributes['displayAs'] && 'edit' === $attributes['context'] ? $attributes['columns'] : -1;

$args = array(
'numberposts' => $number,
'post_type' => 'yt_embed',
'order' => $attributes['order'],
'post_status' => 'publish',
'orderby' => $attributes['sortBy'],
);

if ( ! empty( $attributes['taxTermsSelected'] ) ) {
$args['tax_query'] = array(
'relation' => 'AND',
array(
'taxonomy' => 'embed_cat',
'field' => 'term_id',
'terms' => explode( ',', $attributes['taxTermsSelected'] ),
),
);
}

$embeds = get_posts( $args );
$data_attrs = '';
if ( $attributes['displayAs'] == 'grid' || $attributes['context'] == 'edit') {
$wrapper_classes = 'ck-columns-grid has-' . $attributes['columns'] . '-columns has-' . $attributes['columnsTablet'] . '-columns-tablet has-' . $attributes['columnsMobile'] . '-columns-mobile';
} else {
$wrapper_classes = 'slider-carousel';
$data_attrs = 'data-slick=\'{ "slidesToShow": ' . $attributes['columns'] . ', "slidesToScroll": ' . $attributes['columns'] . ', "responsive": [ { "breakpoint": 1024, "settings": { "slidesToShow": ' . $attributes['columnsTablet'] . ', "slidesToScroll": ' . $attributes['columnsTablet'] . ' } }, { "breakpoint": 600, "settings": { "slidesToShow": ' . $attributes['columnsMobile'] . ', "slidesToScroll": ' . $attributes['columnsMobile'] . ' } } ] }\'';
}

?>
<div <?php echo get_block_wrapper_attributes( array( 'class' => $wrapper_classes ) ); ?> <?php echo $data_attrs; ?>>
<?php
foreach ( $embeds as $embed ) {

$yt = get_field( 'yt_embed_oembed', $embed->ID, false );
$yt_id = '';
if ( strpos( $yt, 'youtu.be' ) !== false ) {
$yt = explode( '/', $yt );
$yt_id = end( $yt );
} else {
$yt = explode( 'v=', $yt );
$yt_id = $yt[1];
}
$description = get_field( 'yt_embed_description', $embed->ID );
if ( ! empty( $description ) ) {
$description = '<div class="embed-description">' . $description . '</div>';
}

if ( ! empty( $yt_id ) ) {

echo '<div class="yt-embed"><lite-youtube
videotitle="' . $embed->post_title . '"
videoid="' . $yt_id . '"
></lite-youtube>
<p class="embed-title">' . $embed->post_title . '</p>' . $description . '
</div>';


}
}
?>
</div>
1 change: 1 addition & 0 deletions build/yt-embed/script.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('jquery'), 'version' => 'e7fefeb72aedcf88f778');
1 change: 1 addition & 0 deletions build/yt-embed/script.js

Large diffs are not rendered by default.

Loading

0 comments on commit 1e60434

Please sign in to comment.