Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
<?php | |
if ( ! defined( 'ABSPATH' ) ) exit; | |
class WordPress_Plugin_Template_Settings { | |
private $dir; | |
private $file; | |
private $assets_dir; | |
private $assets_url; | |
private $settings_base; |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
<?php | |
/** | |
* Test if a WordPress plugin is active | |
*/ | |
if ( is_plugin_active('plugin-directory/plugin-file.php') ) { | |
// the plugin is active | |
} |
The below code is plugin codes used for adding new functionality setup | |
while updating the plugin or activating the plugin. | |
This is simple plugin code and it will add transient while updating or activating the plugin. | |
Clear transient once we finished the operation. | |
======================================================================================= | |
<?php | |
/*Plugin Name: Wordpress Update |
:root { | |
--violation-color: red; /* used for clear issues */ | |
--warning-color: orange; /* used for potential issues we should look into */ | |
} | |
/* IMAGES */ | |
/* | |
* Lazy-Loaded Images Check | |
* ==== |
<?php | |
/* | |
Plugin name: WordPress Plugin Template - Extra Post Info | |
Plugin URI: http://veitchdigital.com/ | |
Description: A simple plugin starter template to add extra info to posts excerpt previews, after the excerpt-content. | |
Author: Ryan Veitch | |
Author http://veitchdigital.com/ | |
Version: 0.1 | |
*/ |
<?php | |
/** | |
* @package MyPlugin | |
*/ | |
//Before playing with this file, see the other file in the gist. Read the comments. | |
if( ! class_exists( 'MyPlugin' ) ) { | |
class MyPlugin { |
<?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 |
In this article I'm going to walk you through process of creating Wordpress plugins. First I'm going to talk about some of the basic concepts in Wordpress plugin development like the actions, hooks, and API's that makes up Wordpress. Then were going to build a plugin where we apply some of the concepts and best practices in developing Wordpress plugins.
###Prerequisites
In order to fully benefit from this tutorial you should have a basic knowledge on PHP. As Wordpress is running on PHP and most of the code that we will be writing will be on PHP. A little bit of knowledge on HTML, CSS and JavaScript is also helpful but not required for this tutorial.
<?php | |
/** | |
* Configuration class to manage settings | |
*/ | |
class WP_Error_Handler_Config { | |
private $config; | |
public function __construct(array $config = []) { | |
$this->config = array_merge([ |