105 lines
3 KiB
PHP
105 lines
3 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Piazza in Festa
|
|
* Plugin URI: https://piazzainfesta.it/widget
|
|
* Description: Show the upcoming local events of the Italian towns you follow: village feasts, concerts, fairs, exhibitions. Shortcode and block, updated daily.
|
|
* Version: 1.0.0
|
|
* Requires at least: 6.5
|
|
* Requires PHP: 7.4
|
|
* Author: Piazza in Festa
|
|
* Author URI: https://piazzainfesta.it
|
|
* License: GPL-2.0-or-later
|
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
* Text Domain: piazza-in-festa
|
|
* Domain Path: /languages
|
|
*
|
|
* @package PiazzaInFesta
|
|
*/
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
define( 'PINFESTA_VERSION', '1.0.0' );
|
|
define( 'PINFESTA_FILE', __FILE__ );
|
|
define( 'PINFESTA_DIR', plugin_dir_path( __FILE__ ) );
|
|
define( 'PINFESTA_URL', plugin_dir_url( __FILE__ ) );
|
|
|
|
/**
|
|
* Base URL of the service that serves the widget.
|
|
*
|
|
* Kept in a filter so a site can point the plugin at a staging instance
|
|
* without editing the plugin files.
|
|
*
|
|
* @return string Base URL, without trailing slash.
|
|
*/
|
|
function pinfesta_base_url() {
|
|
/**
|
|
* Filters the base URL of the Piazza in Festa service.
|
|
*
|
|
* @param string $url Base URL, without trailing slash.
|
|
*/
|
|
$url = apply_filters( 'pinfesta_base_url', 'https://piazzainfesta.it' );
|
|
|
|
return untrailingslashit( esc_url_raw( $url ) );
|
|
}
|
|
|
|
require_once PINFESTA_DIR . 'includes/render.php';
|
|
require_once PINFESTA_DIR . 'includes/shortcode.php';
|
|
require_once PINFESTA_DIR . 'includes/block.php';
|
|
require_once PINFESTA_DIR . 'includes/settings.php';
|
|
|
|
// Translations are not loaded by hand: WordPress finds them on its own, both
|
|
// the ones from translate.wordpress.org and the bundled ones in /languages
|
|
// (Domain Path in the header above). Verified on WordPress 7.1 with an it_IT
|
|
// site: calling load_plugin_textdomain() changes nothing and Plugin Check
|
|
// flags it as discouraged since 4.6.
|
|
|
|
/**
|
|
* Registers the front end assets.
|
|
*
|
|
* They are only enqueued when a widget is actually rendered (see
|
|
* pinfesta_render_iframe), so a page without the block or the shortcode does
|
|
* not load anything.
|
|
*
|
|
* @return void
|
|
*/
|
|
function pinfesta_register_assets() {
|
|
wp_register_style(
|
|
'pinfesta-widget',
|
|
PINFESTA_URL . 'assets/css/widget.css',
|
|
array(),
|
|
PINFESTA_VERSION
|
|
);
|
|
|
|
wp_register_script(
|
|
'pinfesta-resize',
|
|
PINFESTA_URL . 'assets/js/resize.js',
|
|
array(),
|
|
PINFESTA_VERSION,
|
|
true
|
|
);
|
|
|
|
wp_localize_script(
|
|
'pinfesta-resize',
|
|
'pinfestaCfg',
|
|
array( 'origin' => pinfesta_base_url() )
|
|
);
|
|
}
|
|
add_action( 'init', 'pinfesta_register_assets' );
|
|
|
|
/**
|
|
* Adds a settings link on the plugins list, next to Deactivate.
|
|
*
|
|
* @param array $links Existing action links.
|
|
* @return array
|
|
*/
|
|
function pinfesta_action_links( $links ) {
|
|
$url = admin_url( 'options-general.php?page=piazza-in-festa' );
|
|
|
|
array_unshift(
|
|
$links,
|
|
'<a href="' . esc_url( $url ) . '">' . esc_html__( 'Settings', 'piazza-in-festa' ) . '</a>'
|
|
);
|
|
|
|
return $links;
|
|
}
|
|
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'pinfesta_action_links' );
|