Skip to content

Instantly share code, notes, and snippets.

@mwhiteley16
Last active March 14, 2025 14:55
Show Gist options
  • Save mwhiteley16/1f57392dbfb928f3c167887b548272bb to your computer and use it in GitHub Desktop.
Save mwhiteley16/1f57392dbfb928f3c167887b548272bb to your computer and use it in GitHub Desktop.
Feast Mediavine Integration
<?php
/**
* Defines all of the code related to the Mediavine integrations.
*
* @see feast-plugin.php
* @package Feast
*/
namespace Feast\Integrations\Mediavine;
use Feast\WordPress\Database\Settings;
/**
* Script output.
*/
function mcp_prep_scripts() {
if ( ! defined( 'MCP_PLUGIN_DIR' ) ) {
return;
}
$local_model_default_values = [
'optimize_mobile_pagespeed' => true,
'optimize_desktop_pagespeed' => true,
'content_selector' => '.entry-content',
'footer_selector' => '.site-footer',
'content_selector_mobile' => '.entry-content',
'comments_selector' => '',
'sidebar_atf_selector' => '.sidebar-primary .widget-container:nth-last-child(3)',
'sidebar_atf_position' => 'afterend',
'sidebar_btf_selector' => '.mv-sticky-slot',
'sidebar_btf_position' => 'beforeend',
'content_stop_selector' => '',
'sidebar_btf_stop_selector' => '.site-footer',
'custom_css' => '',
'ad_box' => true,
'sidebar_minimum_width' => '1080',
];
/**
* Filters local model overrides
* (Advanced use)
*
* @param array $local_model_values override key/value pairs
*/
$local_model_values = apply_filters( 'mv_trellis_local_script_model', $local_model_default_values );
if ( empty( $local_model_values ) ) {
return;
}
?>
<script id="mv-trellis-localModel" data-cfasync="false">
window.$adManagementConfig = window.$adManagementConfig || {};
window.$adManagementConfig.web = window.$adManagementConfig.web || {};
window.$adManagementConfig.web.localModel = <?php echo wp_json_encode( $local_model_values ); ?>;
</script>
<?php
}
add_action( 'wp_print_scripts', __NAMESPACE__ . '\mcp_prep_scripts', 9 );
/**
* Add entry content selector (Trellis).
*
* @param array $classes The classes array.
*/
function mcp_content_classes_trellis( $classes ) {
if ( ! defined( 'MCP_PLUGIN_DIR' ) ) {
return $classes;
}
if ( is_singular() ) {
$classes[] .= 'mvt-content';
}
return $classes;
}
add_filter( 'mv_trellis_entry_content_classes', __NAMESPACE__ . '\mcp_content_classes_trellis' );
/**
* Add entry content selector (Genesis).
*
* @param array $attributes The attributes array.
*/
function mcp_content_classes_genesis( $attributes ) {
if ( ! defined( 'MCP_PLUGIN_DIR' ) ) {
return $attributes;
}
if ( is_singular() ) {
$attributes['class'] .= ' mvt-content';
}
return $attributes;
}
add_filter( 'genesis_attr_entry-content', __NAMESPACE__ . '\mcp_content_classes_genesis' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment