Skip to content

Instantly share code, notes, and snippets.

@paolosax
paolosax / How to detect if a WordPress plugin is active.php
Created May 14, 2021 11:49 — forked from llgruff/How to detect if a WordPress plugin is active.php
A function you can use to check if plugin is active/loaded for your plugins/themes
<?php
/**
* Detect if a WordPress plugin is active
* A function you can use to check if plugin is active/loaded for your plugins/themes
* @link //gist.github.com/llgruff/c5666bfeded5de69b1aa424aa80cc14f
*/
// When coding plugins that rely on another one, like Private Content for bbPress or Visual Attributes for WooCommerce, you need to make if the WordPress Plugin is active to initialize your plugin routines or display a notice saying that the required plugin must be activated. In this tutorial we’ll see how to detect whether a certain plugin is active in a couple of ways.
## 1. Check whether a certain class or function or constant exists
@paolosax
paolosax / auto-polylang-media.php
Created April 10, 2021 14:06 — forked from sirtimid/auto-polylang-media.php
Translate media automatically when using Polylang in Wordpress
<?php
if ( !function_exists( 'translate_all_media' ) ) {
function translate_all_media() {
global $polylang;
if(!$polylang) return;
// find languages
$langs = array();
@paolosax
paolosax / functions.php
Created December 12, 2018 20:50
Functions
<?php
function hello_world() {
return 'Hello world';
}