Files
SoloFilters/image-filters.php
T

70 lines
1.9 KiB
PHP

<?php
/**
* Plugin Name: Image Filters
* Description: Add Instagram-style CSS filters to images in the block editor.
* Version: 0.1.0
* Requires at least: 6.4
* Requires PHP: 7.4
* Author: ksolo
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: image-filters
* Domain Path: /languages
*
* @package ImageFilters
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'IMAGE_FILTERS_VERSION', '0.1.0' );
define( 'IMAGE_FILTERS_FILE', __FILE__ );
define( 'IMAGE_FILTERS_DIR', plugin_dir_path( __FILE__ ) );
define( 'IMAGE_FILTERS_URL', plugin_dir_url( __FILE__ ) );
/**
* Bootstrap the plugin.
*
* Registers the Filtered Image block from the build directory. The registered
* block type is static (its markup is produced by the JS save function).
*
* @return void
*/
function image_filters_bootstrap(): void {
if ( ! function_exists( 'register_block_type' ) ) {
return;
}
register_block_type(
IMAGE_FILTERS_DIR . 'build',
array(
'render_callback' => 'image_filters_render_block',
)
);
}
add_action( 'plugins_loaded', 'image_filters_bootstrap' );
/**
* Render callback for the Filtered Image block.
*
* Static blocks render their own markup via save.js. The render_callback
* is a placeholder for future server-side logic (e.g. dynamic alt text).
*
* @param array $attributes Block attributes.
* @param string $content Saved block content.
* @return string
*/
function image_filters_render_block( array $attributes, string $content = '' ): string {
return $content;
}
/**
* Load plugin textdomain for translations.
*
* @return void
*/
function image_filters_load_textdomain(): void {
load_plugin_textdomain( 'image-filters', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
add_action( 'init', 'image_filters_load_textdomain' );