Skip to content

Commit

Permalink
add video option #65
Browse files Browse the repository at this point in the history
  • Loading branch information
openmindculture committed Nov 6, 2023
1 parent d4da3b2 commit dc45868
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 4 deletions.
41 changes: 38 additions & 3 deletions mu-plugins/kleiderordnung-register-custom-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/**
* @package KleiderOrdnung
* @author openmindculture
* @version 3.2.2
* @version 3.2.3
*
* @wordpress-plugin
* Version: 3.2.2
* Version: 3.2.3
* Tested up to: 6.4
* Plugin Name: Kleiderordnung Register Custom Post Types
* Text Domain: kleiderordnung-register-custom-post-types
Expand Down Expand Up @@ -359,7 +359,42 @@ function kleiderordnung_register_custom_page_fields() {
),
),
),
) );
));
acf_add_local_field_group( array(
'key' => 'page_field_group_video',
'title' => 'Intro-Video (optional)',
'position' => 'normal',
'fields' => array(
array(
'key' => 'page_intro_video_webm',
'name' => 'page_intro_video_webm',
'type' => 'image',
'label' => 'Video: WEBM-Datei aus Mediathek auswählen/hochladen ("Bild hinzufügen")',
),
array(
'key' => 'page_intro_video_url_mp4',
'name' => 'page_intro_video_url_mp4',
'type' => 'image',
'label' => 'Video: MP4-Datei aus Mediathek auswählen/hochladen ("Bild hinzufügen")',
),
array(
'key' => 'page_intro_video_poster_image_url',
'name' => 'page_intro_video_poster_image_url',
'type' => 'image',
'label' => 'Intro Video Standbild (aus Mediathek auswählen/hochladen)',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
),
);
}

add_action( 'init', 'kleiderordnung_register_post_type_story' );
Expand Down
2 changes: 1 addition & 1 deletion src/front-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
include( KLEIDERORDNUNG_DIR . '/inc/structure/mission.php');
include( KLEIDERORDNUNG_DIR . '/inc/structure/calltoaction.php');
include( KLEIDERORDNUNG_DIR . '/inc/structure/stories.php');
$isNewsTeaser = True;
$isNewsTeaser = true;
include( KLEIDERORDNUNG_DIR . '/inc/structure/news.php');
include( KLEIDERORDNUNG_DIR . '/inc/structure/socialmedia.php');
include( KLEIDERORDNUNG_DIR . '/inc/structure/contact.php');
Expand Down
4 changes: 4 additions & 0 deletions src/inc/structure/intro.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ class="initially-hidden"
<?php echo get_field('page_intro_text', KLEIDERORDNUNG_FRONT_PAGE_ID) ?>
</p>
</div>
<?php
$kleiderordnung_currentPageId = KLEIDERORDNUNG_FRONT_PAGE_ID;
include( KLEIDERORDNUNG_DIR . '/inc/structure/video-from-page-fields.php');
?>
</section>
73 changes: 73 additions & 0 deletions src/inc/structure/video-from-page-fields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/*
* Show Video defined by Custom Page Fields
*
* @package KleiderOrdnung
* @author openmindculture
*/

global /* @type {int} */ $kleiderordnung_currentPageId;

if (!$kleiderordnung_currentPageId || empty($kleiderordnung_currentPageId)) {
$kleiderordnung_currentPageId = KLEIDERORDNUNG_FRONT_PAGE_ID;
}

$kleiderordnung_currentPageHasVideoWebm =
!empty(get_field('page_intro_video_webm', $kleiderordnung_currentPageId)) &&
!empty(get_field('page_intro_video_webm', $kleiderordnung_currentPageId)['url']);
$kleiderordnung_currentPageHasVideoMp4 =
!empty(get_field('page_intro_video_mp4', $kleiderordnung_currentPageId)) &&
!empty(get_field('page_intro_video_mp4', $kleiderordnung_currentPageId)['url']);
$kleiderordnung_currentPageHasVideoPosterImage =
!empty(get_field('page_intro_video_poster_image', $kleiderordnung_currentPageId)) &&
!empty(get_field('page_intro_video_poster_image', $kleiderordnung_currentPageId)['url']);

echo var_export(get_field('page_intro_video_mp4', $kleiderordnung_currentPageId), true);

if ($kleiderordnung_currentPageHasVideoWebm || $kleiderordnung_currentPageHasVideoMp4) : ?>

<video
controls
width="<?php
echo esc_html(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId)['width'])
?>"
height="<?php
echo esc_html(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId)['height'])
?>"
<?php if ($kleiderordnung_currentPageHasVideoPosterImage): ?>
poster="<?php
echo esc_html(get_field(
'page_intro_video_poster_image_url', $kleiderordnung_currentPageId
)['url'])
?>"
<?php endif ?>
>
<?php if ($kleiderordnung_currentPageHasVideoWebm): ?>
<source src="<?php
echo esc_html(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId)['url'])
?>" type="video/webm" />
<?php endif ?>

<?php if ($kleiderordnung_currentPageHasVideoMp4): ?>
<source src="<?php
echo esc_html(get_field('page_intro_video_url_mp4', $kleiderordnung_currentPageId)['url'])
?>" type="video/mp4" />
<?php endif ?>

<?php _e( 'Video', 'kleiderordnung' ) ?> -
<?php _e( 'download as', 'kleiderordnung' ) ?>
<?php if ($kleiderordnung_currentPageHasVideoWebm): ?>
<a href="<?php
echo esc_html(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId)['url'])
?>" />
<?php endif ?>
<?php if ($kleiderordnung_currentPageHasVideoWebm || $kleiderordnung_currentPageHasVideoMp4): ?>
<?php _e( 'or', 'kleiderordnung' ) ?>
<?php endif ?>
<?php if ($kleiderordnung_currentPageHasVideoMp4): ?>
<a href="<?php
echo esc_html(get_field('page_intro_video_url_mp4', $kleiderordnung_currentPageId['url']))
?>"/>
<?php endif ?>
</video>
<?php endif ?>
68 changes: 68 additions & 0 deletions src/inc/structure/video.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/*
* Video
*
* @package KleiderOrdnung
* @author openmindculture
*/
global /* @type {int} */ $kleiderordnung_currentPageId;
if (!$kleiderordnung_currentPageId || empty($kleiderordnung_currentPageId)) {
$kleiderordnung_currentPageId = KLEIDERORDNUNG_FRONT_PAGE_ID;
}
if (
!empty(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId)) ||
!empty(get_field('page_intro_video_url_webp', $kleiderordnung_currentPageId))
): ?>
Verflixte Zeitverschwendung! <h2>page_intro_video_poster_image_url</h2>
gettype(get_field('page_intro_video_poster_image_url', $kleiderordnung_currentPageId))):
<?php echo gettype(get_field('page_intro_video_poster_image_url', $kleiderordnung_currentPageId)) ?>
<hr>var_export(get_field..., true):<br><br><?php
echo var_export( get_field('page_intro_video_poster_image_url', $kleiderordnung_currentPageId) , true);
?>
<hr>
<video
controls
width="250"
<?php if (
!empty(get_field('page_intro_video_poster_image_url', $kleiderordnung_currentPageId)) &&
!empty(get_field('page_intro_video_poster_image_url', $kleiderordnung_currentPageId)['url'])
): ?>
poster="<?php
echo esc_html(get_field(
'page_intro_video_poster_image_url', $kleiderordnung_currentPageId
)['url'])
?>"
<?php endif ?>
>
<?php if (!empty(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId))): ?>
<source src="<?php
echo esc_html(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId))
?>" type="video/webm" />
<?php endif ?>

<?php if (!empty(get_field('page_intro_video_url_mp4', $kleiderordnung_currentPageId))): ?>
<source src="<?php
echo esc_html(get_field('page_intro_video_url_mp4', $kleiderordnung_currentPageId))
?>" type="video/mp4" />
<?php endif ?>

<?php _e( 'Video', 'kleiderordnung' ) ?> -
<?php _e( 'download as', 'kleiderordnung' ) ?>
<?php if (!empty(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId))): ?>
<a href="<?php
echo esc_html(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId))
?>" />
<?php endif ?>
<?php if (
!empty(get_field('page_intro_video_url_webm', $kleiderordnung_currentPageId)) ||
!empty(get_field('page_intro_video_url_webp', $kleiderordnung_currentPageId))
): ?>
<?php _e( 'or', 'kleiderordnung' ) ?>
<?php endif ?>
<?php if (!empty(get_field('page_intro_video_url_mp4', $kleiderordnung_currentPageId))): ?>
<a href="<?php
echo esc_html(get_field('page_intro_video_url_mp4', $kleiderordnung_currentPageId))
?>"/>
<?php endif ?>
</video>
<?php endif ?>

0 comments on commit dc45868

Please sign in to comment.