71 lines
2.2 KiB
PHP
71 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: SoloFilters Image Enhancements
|
|
* 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: solofilters-image-enhancements
|
|
* Domain Path: /languages
|
|
*
|
|
* @package SoloFiltersImageEnhancements
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
define( 'SOLOFILTERS_IMAGE_ENHANCEMENTS_VERSION', '0.1.0' );
|
|
define( 'SOLOFILTERS_IMAGE_ENHANCEMENTS_FILE', __FILE__ );
|
|
define( 'SOLOFILTERS_IMAGE_ENHANCEMENTS_DIR', plugin_dir_path( __FILE__ ) );
|
|
define( 'SOLOFILTERS_IMAGE_ENHANCEMENTS_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 solofilters_image_enhancements_bootstrap(): void {
|
|
if ( ! function_exists( 'register_block_type' ) ) {
|
|
return;
|
|
}
|
|
|
|
register_block_type(
|
|
SOLOFILTERS_IMAGE_ENHANCEMENTS_DIR . 'build',
|
|
array(
|
|
'render_callback' => 'solofilters_image_enhancements_render_block',
|
|
)
|
|
);
|
|
}
|
|
add_action( 'plugins_loaded', 'solofilters_image_enhancements_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 solofilters_image_enhancements_render_block( array $attributes, string $content = '' ): string {
|
|
return $content;
|
|
}
|
|
|
|
/**
|
|
* Load plugin textdomain for translations.
|
|
*
|
|
* @return void
|
|
*/
|
|
function solofilters_image_enhancements_load_textdomain(): void {
|
|
load_plugin_textdomain( 'solofilters-image-enhancements', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
|
}
|
|
add_action( 'init', 'solofilters_image_enhancements_load_textdomain' );
|