Skip to content

Instantly share code, notes, and snippets.

View constantin-b's full-sized avatar

Constantin Boiangiu constantin-b

View GitHub Profile
@constantin-b
constantin-b / functions.php
Created January 15, 2024 10:54
WPYTHub - convert post content to UTF-8
/**
* Convert the post content to UTF-8 in WPYTHub importer.
*/
add_action(
'cbc_video_post_content',
function( $content ){
if( function_exists( 'mb_convert_encoding' ) ) {
$content = mb_convert_encoding( $content, 'UTF-8', 'auto' );
}
@constantin-b
constantin-b / functions.php
Created December 8, 2023 18:24
Vimeotheque - enable auto captions automatically
/**
* Enable auto captions on video embeds.
*/
add_filter(
'vimeotheque\player\embed-parameters',
function( $embed_options ){
if( !is_array($embed_options) ){
$embed_options = array();
}
@constantin-b
constantin-b / functions.php
Created June 19, 2023 07:49
Vimeotheque - remove video post taxonomies UI from admin menu
add_action(
'init',
function() {
/**
* Remove UI.
*
* Remove UI for Vimeotheque custom post type taxonomies.
*
* @param array $args Array of arguments for registering a taxonomy.
* @param string $taxonomy Taxonomy key.
@constantin-b
constantin-b / functions.php
Created June 19, 2023 07:31
Vimeotheque - change post type archive title
/**
* Change page title.
*
* Change the page title for post type "vimeo-video" when displaying the post type archive.
*
* @param string $title The post title.
* @return string
*/
add_filter(
'pre_get_document_title',
@constantin-b
constantin-b / functions.php
Last active April 14, 2023 11:34
Vimeotheque PRO - store video URL in theme Coppola portfolio-item meta field
/**
* Store video URL on post meta.
*/
add_action(
'vimeotheque\import_success',
function( $post_id, $video ){
$post = get_post( $post_id );
if( $post && 'portfolio-item' == $post->post_type ) {
update_post_meta(
@constantin-b
constantin-b / functions.php
Created April 6, 2023 08:41
Vimeotheque PRO - import videos as post type "portfolio-item".
/**
* Import videos as post type "portfolio-item".
*/
add_filter(
'vimeotheque_pro\post\import_post_type',
function(){
return 'portfolio-item';
}
);
@constantin-b
constantin-b / functions.php
Last active February 16, 2023 07:22
Vimeotheque - modify post title before import
/**
* Remove file extension if shown into the title retrieved from Vimeo.
*/
add_filter(
'vimeotheque\import_post_title',
function( $title ){
return str_replace( '.mp4', '', $title );
}
);
@constantin-b
constantin-b / functions.php
Created January 9, 2023 11:49
Vimeotheque Lite 2.2 - add theme support for templates
/**
* Declare theme support for Vimeotheque templates.
*/
add_theme_support( 'vimeotheque' );
/**
* Declare theme support for Vimeotheque video playback end card.
*/
add_theme_support( 'vimeotheque-next-video-card' );
@constantin-b
constantin-b / functions.php
Created December 7, 2022 11:32
VideographyWP PRO - allow embedding when using the WP Loop block
/**
* When using the WP Loop block, the post being displayed into the loop doesn't have the same ID with the main post/page
* that the WP Query is displaying. To avoid not having the embeds skipped, the the filter to skip the post ID check to (bool) true.
*/
add_filter(
'cvwp_image_embed_skip_post_check',
'__return_true'
);
@constantin-b
constantin-b / functions.php
Created October 4, 2022 10:56
Vimeotheque 2 - add download link to video post custom field
/**
* Add 'download' field to API response
*
* @param array $fields Additional fields allowed in API response
*
* @return array
*/
function vmtq_addon_add_dist_links( $fields ){
$fields[] = 'download';
return $fields;