# ultimate-post-kit/trunk/ultimate-post-kit.php

Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider &amp; Blog Layout Widgets, version trunk. 228 lines.

- Page: https://pluginprobe.com/plugins/ultimate-post-kit/trunk/code/ultimate-post-kit.php
- Raw: https://pluginprobe.com/plugins/ultimate-post-kit/trunk/raw/ultimate-post-kit.php
- Modified: 2026-09-13T06:20:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ultimate-post-kit/trunk/code/ultimate-post-kit.php#L10-L20`.

```php
<?php

/**
 * Plugin Name: Ultimate Post Kit
 * Plugin URI: https://postkit.pro/
 * Description: <a href="https://postkit.pro/">Ultimate Post Kit</a> is a packed of post related elementor widgets. This plugin gives you post related widget features for elementor page builder plugin.
 * Version: 4.5.4
 * Author: BdThemes
 * Author URI: https://bdthemes.com/
 * Text Domain: ultimate-post-kit
 * Domain Path: /languages
 * License: GPL3
 * Elementor requires at least: 4.0.0
 * Elementor tested up to: 4.2.4
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// Some pre define value for easy use
define( 'BDTUPK_VER', '4.5.4' );

/**
 * Minimum Pro version this Free/Core release is API compatible with.
 *
 * Required on Core/Base file changes. The Pro add-on extends base classes and
 * calls helpers that live here, so whenever those signatures change a matching
 * Pro must be released and this constant bumped to it. An older Pro is only
 * warned about, never blocked, so the Free plugin stays fully functional on
 * its own.
 */
define( 'BDTUPK_PRO_REQUIRED_VERSION', '4.5.2' );

define( 'BDTUPK__FILE__', __FILE__ );

/**
 * Loads translations
 *
 * @return void
 */

// Translations for plugins hosted on WordPress.org load automatically since WP 4.6.


if ( ! function_exists( '_is_upk_pro_installed' ) ) {

	// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- established function name relied on across the plugin family / feedback SDK; renaming would break integration.
	function _is_upk_pro_installed() {

		if ( ! function_exists( 'get_plugins' ) ) {
			require_once ABSPATH . 'wp-admin/includes/plugin.php';
		}

		$file_path         = 'ultimate-post-kit-pro/ultimate-post-kit-pro.php';
		$installed_plugins = get_plugins();

		return isset( $installed_plugins[ $file_path ] );
	}
}

if ( ! function_exists( '_is_upk_pro_activated' ) ) {

	// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- established function name relied on across the plugin family / feedback SDK; renaming would break integration.
	function _is_upk_pro_activated() {

		if ( ! function_exists( 'get_plugins' ) ) {
			require_once ABSPATH . 'wp-admin/includes/plugin.php';
		}

		$file_path = 'ultimate-post-kit-pro/ultimate-post-kit-pro.php';

		if ( is_plugin_active( $file_path ) ) {
			return true;
		}

		return false;
	}
}

if ( ! function_exists( '_is_upk_pro_version_sufficient' ) ) {

	// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- matches the established _is_upk_* helper naming used across the plugin family.
	function _is_upk_pro_version_sufficient() {

		// Pro is not loaded, so there is nothing to be incompatible with.
		if ( ! defined( 'BDTUPK_PRO_VER' ) ) {
			return true;
		}

		return version_compare( BDTUPK_PRO_VER, BDTUPK_PRO_REQUIRED_VERSION, '>=' );
	}
}

// Helper function here
require_once ( dirname( __FILE__ ) . '/includes/helper.php' );

if ( ! _is_upk_pro_activated() ) {
	require_once BDTUPK_INC_PATH . 'class-pro-widget-map.php';
}

if ( function_exists( 'upk_license_validation' ) && true !== upk_license_validation() ) {
	require_once BDTUPK_INC_PATH . 'class-pro-widget-map.php';
}

require_once ( dirname( __FILE__ ) . '/includes/utils.php' );

// Widgets filters here
require_once ( BDTUPK_INC_PATH . 'ultimate-post-kit-filters.php' );


/**
 * Plugin load here correctly
 * Also loaded the language file from here
 */
function ultimate_post_kit_load_plugin() {

	if ( ! did_action( 'elementor/loaded' ) ) {
		add_action( 'admin_notices', 'ultimate_post_kit_fail_load' );

		return;
	}

	// An outdated Pro is warned about but never blocked; Free must keep working.
	if ( ! _is_upk_pro_version_sufficient() ) {
		add_action( 'admin_notices', 'ultimate_post_kit_pro_version_not_sufficient' );
	}

	require_once( dirname( __FILE__ ) . '/includes/setup-wizard/init.php' );

	// Element pack widget and assets loader
	require_once ( BDTUPK_PATH . 'loader.php' );
}

add_action( 'plugins_loaded', 'ultimate_post_kit_load_plugin' );


/**
 * Warn when the installed Pro add-on is older than this Free/Core release
 * expects. Pro is still loaded, so nothing breaks silently on the front end.
 */
function ultimate_post_kit_pro_version_not_sufficient() {
	if ( ! current_user_can( 'update_plugins' ) ) {
		return;
	}

	$admin_message = '<p>' . sprintf(
		/* translators: 1: installed Ultimate Post Kit Pro version, 2: minimum required Ultimate Post Kit Pro version */
		esc_html__( 'Ops! Ultimate Post Kit Pro %1$s is older than this version of the Free/Core plugin supports. Please update Ultimate Post Kit Pro to at least version %2$s.', 'ultimate-post-kit' ),
		esc_html( BDTUPK_PRO_VER ),
		esc_html( BDTUPK_PRO_REQUIRED_VERSION )
	) . '</p>';

	echo '<div class="error">' . wp_kses_post( $admin_message ) . '</div>';
}

/**
 * Check Elementor installed and activated correctly
 */
function ultimate_post_kit_fail_load() {
	$screen = get_current_screen();
	if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
		return;
	}

	$plugin = 'elementor/elementor.php';

	if ( _is_elementor_installed() ) {
		if ( ! current_user_can( 'activate_plugins' ) ) {
			return;
		}
		$activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
		$admin_message  = '<p>' . esc_html__( 'Ops! Ultimate Post Kit not working because you need to activate the Elementor plugin first.', 'ultimate-post-kit' ) . '</p>';
		$admin_message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $activation_url, esc_html__( 'Activate Elementor Now', 'ultimate-post-kit' ) ) . '</p>';
	} else {
		if ( ! current_user_can( 'install_plugins' ) ) {
			return;
		}
		$install_url   = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
		$admin_message = '<p>' . esc_html__( 'Ops! Ultimate Post Kit not working because you need to install the Elementor plugin', 'ultimate-post-kit' ) . '</p>';
		$admin_message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $install_url, esc_html__( 'Install Elementor Now', 'ultimate-post-kit' ) ) . '</p>';
	}

	echo '<div class="error">' . wp_kses_post( $admin_message ) . '</div>';
}

/**
 * Check the elementor installed or not
 */
if ( ! function_exists( '_is_elementor_installed' ) ) {

	// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- established function name relied on across the plugin family / feedback SDK; renaming would break integration.
	function _is_elementor_installed() {
		$file_path         = 'elementor/elementor.php';
		$installed_plugins = get_plugins();

		return isset( $installed_plugins[ $file_path ] );
	}
}



/**
 * Review Automation Integration
 */

if ( ! function_exists( 'ultimate_post_kit_reviews_bootstrap' ) ) {
	function ultimate_post_kit_reviews_bootstrap() {

		require_once BDTUPK_INC_PATH . 'feedback-hub/start.php';

		ultimate_post_kit_reviews_init( array(
			'sdk_version'  => '1.0.0',
			'plugin_name'  => 'Ultimate Post Kit',
			'plugin_icon'  => BDTUPK_ASSETS_URL . 'images/logo.svg',
			'slug'         => 'ultimate_post_kit_options',
			'menu'         => array(
				'slug' => 'ultimate_post_kit_options',
			),
			'review_url'   => 'https://bdt.to/ultimate-post-kit-elementor-addons-review',
			'plugin_title' => 'Yay! Great that you\'re using Ultimate Post Kit',
			'plugin_msg'   => '<p>Loved using Ultimate Post Kit on your website? Share your experience in a review and help us spread the love to everyone right now. Good words will help the community.</p>',
		) );

	}
	add_action( 'admin_init', 'ultimate_post_kit_reviews_bootstrap' );
}

```
