responsive-tabs-for-elementor
Last commit date
assets
4 weeks ago
includes
4 weeks ago
widgets
4 weeks ago
widgets-templates
4 weeks ago
class-responsive-tabs-for-elementor.php
4 weeks ago
class-widgets.php
4 weeks ago
readme.txt
4 weeks ago
responsive-tabs-for-elementor.php
4 weeks ago
class-responsive-tabs-for-elementor.php
217 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Responsive_Tabs_For_Elementor class. |
| 4 | * |
| 5 | * @category Class |
| 6 | * @package ResponsiveTabsForElementor |
| 7 | * @subpackage WordPress |
| 8 | * @author UAPP GROUP |
| 9 | * @copyright 2026 UAPP GROUP |
| 10 | * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0-only |
| 11 | * @link |
| 12 | * @since 11.0.1 |
| 13 | * php version 7.4.1 |
| 14 | */ |
| 15 | if (!defined('ABSPATH')) { |
| 16 | // Exit if accessed directly. |
| 17 | exit; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Main Responsive Tabs For Elementor Class |
| 22 | * |
| 23 | * The init class that runs the Responsive Tabs For Elementor plugin. |
| 24 | * Intended To make sure that the plugin's minimum requirements are met. |
| 25 | */ |
| 26 | final class Responsive_Tabs_For_Elementor |
| 27 | { |
| 28 | /** |
| 29 | * Minimum Elementor Version |
| 30 | * |
| 31 | * @since 11.0.1 |
| 32 | * @var string Minimum Elementor version required to run the plugin. |
| 33 | */ |
| 34 | const MINIMUM_ELEMENTOR_VERSION = '3.10.0'; |
| 35 | /** |
| 36 | * Minimum PHP Version |
| 37 | * |
| 38 | * @since 11.0.1 |
| 39 | * @var string Minimum PHP version required to run the plugin. |
| 40 | */ |
| 41 | const MINIMUM_PHP_VERSION = '7.4.1'; |
| 42 | |
| 43 | /** |
| 44 | * Constructor |
| 45 | * |
| 46 | * @since 11.0.1 |
| 47 | * @access public |
| 48 | */ |
| 49 | public function __construct() |
| 50 | { |
| 51 | add_action('elementor/elements/categories_registered', [$this, 'register_category']); |
| 52 | // Load the translation. |
| 53 | add_action('init', [$this, 'i18n']); |
| 54 | // Initialize the plugin. |
| 55 | add_action('plugins_loaded', [$this, 'init']); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * |
| 60 | * Register Responsive Tabs For Elementor category |
| 61 | * |
| 62 | */ |
| 63 | public function register_category($elements_manager) |
| 64 | { |
| 65 | $elements_manager->add_category( |
| 66 | 'responsive_tabs', |
| 67 | [ |
| 68 | 'title' => __('Responsive Tabs', 'responsive-tabs-for-elementor'), |
| 69 | 'icon' => 'fa fa-plug', |
| 70 | ] |
| 71 | ); |
| 72 | |
| 73 | $elements_manager->add_category( |
| 74 | 'responsive_accordions', |
| 75 | [ |
| 76 | 'title' => __('Responsive Accordions', 'responsive-tabs-for-elementor'), |
| 77 | 'icon' => 'fa fa-plug', |
| 78 | ] |
| 79 | ); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Load Textdomain |
| 84 | * |
| 85 | * Load plugin localization files. |
| 86 | * Fired by `init` action hook. |
| 87 | * |
| 88 | * @since 11.0.1 |
| 89 | * @access public |
| 90 | */ |
| 91 | public function i18n() |
| 92 | { |
| 93 | load_plugin_textdomain('responsive-tabs-for-elementor'); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Initialize the plugin |
| 98 | * |
| 99 | * Validates that Elementor is already loaded. |
| 100 | * Checks for basic plugin requirements, if one check fail don't continue, |
| 101 | * if all check have passed include the plugin class. |
| 102 | * |
| 103 | * Fired by `plugins_loaded` action hook. |
| 104 | * |
| 105 | * @since 11.0.1 |
| 106 | * @access public |
| 107 | */ |
| 108 | public function init() |
| 109 | { |
| 110 | // Check if Elementor installed and activated. |
| 111 | if (!did_action('elementor/loaded')) { |
| 112 | add_action('admin_notices', [$this, 'admin_notice_missing_main_plugin']); |
| 113 | return; |
| 114 | } |
| 115 | // Check for required Elementor version. |
| 116 | if (!version_compare(ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=')) { |
| 117 | add_action('admin_notices', [$this, 'admin_notice_minimum_elementor_version']); |
| 118 | return; |
| 119 | } |
| 120 | // Check for required PHP version. |
| 121 | if (version_compare(PHP_VERSION, self::MINIMUM_PHP_VERSION, '<')) { |
| 122 | add_action('admin_notices', [$this, 'admin_notice_minimum_php_version']); |
| 123 | return; |
| 124 | } |
| 125 | // Once we get here, We have passed all validation checks so we can safely include our widgets. |
| 126 | require_once plugin_dir_path( RESPONSIVE_TABS_FOR_ELEMENTOR ) . 'includes/class-responsive-tabs-assets.php'; |
| 127 | require_once 'class-widgets.php'; |
| 128 | |
| 129 | // Elementor Editor Styles |
| 130 | add_action('elementor/editor/after_enqueue_scripts', [__CLASS__, 'editor_scripts']); |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * |
| 135 | * Enqueue Elementor Editor Styles |
| 136 | * |
| 137 | */ |
| 138 | public static function editor_scripts() |
| 139 | { |
| 140 | wp_enqueue_style('responsive-tabs-editor', plugins_url('/assets/css/responsive-tabs-editor.min.css', RESPONSIVE_TABS_FOR_ELEMENTOR)); |
| 141 | |
| 142 | require_once 'widgets/hover-image-reveal-tabs/handler/hover-image-reveal-tabs-handler.php'; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Admin notice |
| 147 | * |
| 148 | * Warning when the site doesn't have Elementor installed or activated. |
| 149 | * |
| 150 | * @since 11.0.1 |
| 151 | * @access public |
| 152 | */ |
| 153 | public function admin_notice_missing_main_plugin() |
| 154 | { |
| 155 | deactivate_plugins(plugin_basename(RESPONSIVE_TABS_FOR_ELEMENTOR)); |
| 156 | printf( |
| 157 | sprintf( |
| 158 | '<div class="notice notice-warning is-dismissible"><p><strong>"%1$s"</strong> requires <strong>"%2$s"</strong> to be installed and activated.</p></div>', |
| 159 | 'Responsive Tabs For Elementor', |
| 160 | 'Elementor' |
| 161 | ) |
| 162 | ); |
| 163 | |
| 164 | echo '<style>#message { display: none; }</style>'; |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * Admin notice |
| 169 | * |
| 170 | * Warning when the site doesn't have a minimum required Elementor version. |
| 171 | * |
| 172 | * @since 11.0.1 |
| 173 | * @access public |
| 174 | */ |
| 175 | public function admin_notice_minimum_elementor_version() |
| 176 | { |
| 177 | deactivate_plugins(plugin_basename(RESPONSIVE_TABS_FOR_ELEMENTOR)); |
| 178 | printf( |
| 179 | sprintf( |
| 180 | |
| 181 | '<div class="notice notice-warning is-dismissible"><p><strong>"%1$s"</strong> requires <strong>"%2$s"</strong> version %3$s or greater.</p></div>', |
| 182 | 'Responsive Tabs For Elementor', |
| 183 | 'Elementor', |
| 184 | self::MINIMUM_ELEMENTOR_VERSION |
| 185 | ) |
| 186 | ); |
| 187 | |
| 188 | echo '<style>#message { display: none; }</style>'; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Admin notice |
| 193 | * |
| 194 | * Warning when the site doesn't have a minimum required PHP version. |
| 195 | * |
| 196 | * @since 11.0.1 |
| 197 | * @access public |
| 198 | */ |
| 199 | public function admin_notice_minimum_php_version() |
| 200 | { |
| 201 | deactivate_plugins(plugin_basename(RESPONSIVE_TABS_FOR_ELEMENTOR)); |
| 202 | printf( |
| 203 | sprintf( |
| 204 | '<div class="notice notice-warning is-dismissible"><p><strong>"%1$s"</strong> requires <strong>"%2$s"</strong> version %3$s or greater.</p></div>', |
| 205 | 'Responsive Tabs For Elementor', |
| 206 | 'Elementor', |
| 207 | self::MINIMUM_PHP_VERSION |
| 208 | ) |
| 209 | ); |
| 210 | |
| 211 | echo '<style>#message { display: none; }</style>'; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | // Instantiate Responsive_Tabs_For_Elementor. |
| 216 | new Responsive_Tabs_For_Elementor(); |
| 217 |