How to add a plugin with hooks and filters

I have created a plugin. Now I want to use it inside of my code, but I don’t know how to add it. I have seen things about actions and filters and how to use them, but all of these aren’t very clear to me on where to use them.

/* Constructor for setting values to the propeties. Make sure to select the right breakpoint with the right image*/
public function __construct($imgPath, $landscapeSelectors, $portraitSelectors, $figureClass, $landscapeBreakpoints, $portraitBreakpoints) {
$this->setImgPath($imgPath);
$this->setLandscapeSelectors($landscapeSelectors);
$this->setPortraitSelectors($portraitSelectors);
$this->setFigureClass($figureClass);
$this->setLandscapeBreakpoints($landscapeBreakpoints);
$this->setPortraitBreakpoints($portraitBreakpoints);
}

/* The picture element is build inside here */
public function createHeroImage() {
/* Set the base of the figure */
$this->setHeroImage(“<figure style=’margin-bottom: -7px;’ class='”.$this->getFigureClass()[‘figure’].”‘>
<picture class='”.$this->getFigureClass()[‘figure-div’].”‘>
“);

$this->landscapeImage();

$this->portraitImage();

$this->setHeroImage($this->getHeroImage() . “<img id=’hero-image’ style=’object-fit: cover; height: calc((16 / 9) * 100%)’ alt='”.$this->getImgPath()[‘landscapeImage’][‘alt’].”‘ src='”.$this->getImgPath()[‘portraitImage’][‘sizes’][$this->getLandscapeSelectors()[0]].”‘>”);

$this->setHeroImage($this->getHeroImage() . “</picture>
</figure>”);

return $this->getHeroImage();
}

I want to use my plugin on multiple locations. Every location use a slightly different set of parameters for the constructor.So if there is anyone who can give me a clear answer on this.

Read more here:: How to add a plugin with hooks and filters

Leave a Reply

Your email address will not be published. Required fields are marked *