.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( defined( 'ALPHAPRICETABLE_PLUGIN_FILE' ) && realpath( (string) ALPHAPRICETABLE_PLUGIN_FILE ) !== realpath( __FILE__ ) ) {
if ( ! function_exists( 'alpha_price_table_for_elementor_duplicate_copy_notice' ) ) {
/**
* Display a notice when another copy of the plugin is already active.
*/
function alpha_price_table_for_elementor_duplicate_copy_notice(): void {
printf(
'
',
esc_html__( 'Alpha Price Table For Elementor is already active from another plugin folder. Deactivate and delete the old copy before activating this one, or install the update using a ZIP whose top-level folder is alpha-price-table-for-elementor.', 'alpha-price-table-for-elementor' )
);
}
}
add_action( 'admin_notices', 'alpha_price_table_for_elementor_duplicate_copy_notice' );
register_activation_hook(
__FILE__,
static function (): void {
if ( ! function_exists( 'deactivate_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
deactivate_plugins( plugin_basename( __FILE__ ) );
wp_die(
esc_html__( 'Alpha Price Table For Elementor is already active from another plugin folder. Deactivate and delete the old copy before activating this one, or install the update using a ZIP whose top-level folder is alpha-price-table-for-elementor.', 'alpha-price-table-for-elementor' ),
esc_html__( 'Plugin activation blocked', 'alpha-price-table-for-elementor' ),
array( 'back_link' => true )
);
}
);
return;
}
define( 'ALPHAPRICETABLE_VERSION', '1.3.0' );
define( 'ALPHAPRICETABLE_PLUGIN_FILE', __FILE__ );
define( 'ALPHAPRICETABLE_PLUGIN_URL', plugin_dir_url( ALPHAPRICETABLE_PLUGIN_FILE ) );
define( 'ALPHAPRICETABLE_PLUGIN_PATH', plugin_dir_path( ALPHAPRICETABLE_PLUGIN_FILE ) );
define( 'ALPHAPRICETABLE_ASSETS_URL', trailingslashit( ALPHAPRICETABLE_PLUGIN_URL . 'assets' ) );
define( 'ALPHAPRICETABLE_INCLUDES_PATH', trailingslashit( ALPHAPRICETABLE_PLUGIN_PATH . 'includes' ) );
define( 'ALPHAPRICETABLE_LANGUAGES_PATH', trailingslashit( ALPHAPRICETABLE_PLUGIN_PATH . 'languages' ) );
define( 'ALPHAPRICETABLE_PLUGIN_BASENAME', plugin_basename( ALPHAPRICETABLE_PLUGIN_FILE ) );
/**
* Initialize the Alpha Price Table plugin.
*
* @since 1.0.6
*/
function alpha_price_table_for_elementor_init() {
// Check if Elementor is installed and activated.
if ( ! did_action( 'elementor/loaded' ) ) {
add_action( 'admin_notices', 'alpha_price_table_for_elementor_missing_elementor_notice' );
return;
}
// Include the main plugin class.
include_once ALPHAPRICETABLE_INCLUDES_PATH . 'class-alpha-price-table.php';
// Initialize the plugin.
\Elementor_Alpha_Price_Table_Addon\Alpha_Price_Table_For_Elementor::instance();
}
add_action( 'plugins_loaded', 'alpha_price_table_for_elementor_init' );
/**
* Display an admin notice if Elementor is not installed or activated.
*
* @since 1.0.6
*/
function alpha_price_table_for_elementor_missing_elementor_notice() {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
$plugin = 'elementor/elementor.php';
$is_elementor_installed = file_exists( WP_PLUGIN_DIR . '/' . $plugin );
if ( $is_elementor_installed ) {
$action_url = wp_nonce_url(
self_admin_url( 'plugins.php?action=activate&plugin=' . $plugin ),
'activate-plugin_' . $plugin
);
$action_text = __( 'Activate Elementor Now', 'alpha-price-table-for-elementor' );
/* translators: %1$s: Plugin name, %2$s: Action link */
$message_template = __( '%1$s requires Elementor to be activated. %2$s', 'alpha-price-table-for-elementor' );
} else {
$action_url = wp_nonce_url(
self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ),
'install-plugin_elementor'
);
$action_text = __( 'Install Elementor Now', 'alpha-price-table-for-elementor' );
/* translators: %1$s: Plugin name, %2$s: Action link */
$message_template = __( '%1$s requires Elementor to be installed and activated. %2$s', 'alpha-price-table-for-elementor' );
}
// Safely construct the plugin name and action link.
$plugin_name = '' . esc_html__( 'Alpha Price Table For Elementor', 'alpha-price-table-for-elementor' ) . '';
$action_link = '' . esc_html( $action_text ) . '';
// Combine message template with placeholders.
$message = sprintf(
$message_template,
$plugin_name,
$action_link
);
// Output the notice with the allowed HTML tags.
$allowed_html = array(
'strong' => array(),
'a' => array(
'href' => array(),
'class' => array(),
),
'div' => array(
'class' => array(),
),
'p' => array(),
);
printf(
'%s
',
wp_kses( '' . $message . '
', $allowed_html )
);
}