-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register Elementor and Elementor Pro compatibility
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
includes/Compatibility/Plugins/Elementor/class-compatibility.php
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,83 @@ | ||
<?php | ||
/** | ||
* Elementor's compatibility handler. | ||
* | ||
* @package RSFV | ||
*/ | ||
|
||
namespace RSFV\Compatibility\Plugins\Elementor; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
use RSFV\Compatibility\Plugins\Base_Compatibility; | ||
use RSFV\FrontEnd; | ||
|
||
/** | ||
* Class Compatibility | ||
* | ||
* @package RSFV | ||
*/ | ||
class Compatibility extends Base_Compatibility { | ||
/** | ||
* Class instance. | ||
* | ||
* @var $instance | ||
*/ | ||
protected static $instance; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param string $id Compat ID. | ||
* @param string $title Compat title. | ||
*/ | ||
public function __construct( $id, $title ) { | ||
parent::__construct( $id, $title ); | ||
|
||
$this->setup(); | ||
} | ||
|
||
/** | ||
* Sets up hooks and filters. | ||
* | ||
* @return void | ||
*/ | ||
public function setup() { | ||
add_filter( 'elementor/image_size/get_attachment_image_html', array( $this, 'update_with_video_html' ), 10, 4 ); | ||
} | ||
|
||
/** | ||
* Override Elementor Pro's post widget featured image html. | ||
* | ||
* @since 0.8.6 | ||
* | ||
* @param string $html ex html markup. | ||
* @param array $settings Settings array of parent widget/element. | ||
* @param string $image_size_key Image size key. | ||
* @param string $image_key Image key. | ||
* | ||
* @return string | ||
*/ | ||
public function update_with_video_html( $html, $settings, $image_size_key, $image_key ) { | ||
// Exit early if Elementor Pro isn't active. | ||
if ( ! class_exists( 'ElementorPro\Plugin' ) ) { | ||
return $html; | ||
} | ||
|
||
// Check if the image markup is from somewhere else than post/archive widgets. | ||
if ( $settings && ! isset( $settings['posts_post_type'] ) ) { | ||
return $html; | ||
} | ||
|
||
global $post; | ||
|
||
// Check if the $post object is not defined. | ||
if ( 'object' !== gettype( $post ) ) { | ||
return $html; | ||
} | ||
|
||
$post_id = $post->ID; | ||
|
||
return FrontEnd::get_featured_video_markup( $post_id, $html ); | ||
} | ||
} |
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