Changeset 3427512
- Timestamp:
- 12/26/2025 03:20:04 AM (3 months ago)
- Location:
- wpdm-elementor/trunk
- Files:
-
- 2 added
- 19 edited
-
composer.json (added)
-
readme.txt (modified) (3 diffs)
-
src/Main.php (modified) (4 diffs)
-
src/api/API.php (modified) (1 diff)
-
src/constants.php (modified) (1 diff)
-
src/helper-functions.php (modified) (1 diff)
-
src/includes.php (modified) (1 diff)
-
src/widgets/AllPackagesWidget.php (modified) (3 diffs)
-
src/widgets/BaseWidget.php (added)
-
src/widgets/CategoryWidget.php (modified) (5 diffs)
-
src/widgets/DirectLinkWidget.php (modified) (1 diff)
-
src/widgets/FrontendWidget.php (modified) (4 diffs)
-
src/widgets/LoginFormWidget.php (modified) (4 diffs)
-
src/widgets/PackageWidget.php (modified) (2 diffs)
-
src/widgets/PackagesWidget.php (modified) (9 diffs)
-
src/widgets/RegFormWidget.php (modified) (4 diffs)
-
src/widgets/SearchResultWidget.php (modified) (4 diffs)
-
src/widgets/TagWidget.php (modified) (3 diffs)
-
src/widgets/UserDashboardWidget.php (modified) (5 diffs)
-
src/widgets/UserProfileWidget.php (modified) (2 diffs)
-
wpdm-elementor.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpdm-elementor/trunk/readme.txt
r3259585 r3427512 4 4 Tags: download manager, elementor, document management, file manager, digital store, ecommerce, document management plugin, download monitor 5 5 Requires at least: 5.3 6 Tested up to: 6. 76 Tested up to: 6.9 7 7 License: GPLv2 or later 8 8 … … 12 12 == Description == 13 13 14 When you are using elementor and download manager together, you will not need to write download manager shortcodes manually anymore, this plugin provides configurable elementor modules for all download manager shortcode.14 When you are using Elementor and Download Manager together, you will not need to write download manager shortcodes manually anymore. This plugin provides configurable Elementor widgets for all Download Manager features. 15 15 16 16 = Addons = 17 17 * Package - Embed a single file/package 18 * Packages - Embed all packages with various filter 18 * Packages - Embed all packages with various filters 19 19 * Packages by Category 20 20 * Packages by Tags 21 * All Downloads Table21 * Packages Table - Visual table builder with drag-and-drop column configuration 22 22 * Search and Search Result 23 23 * User Registration Form 24 24 * User Login Form 25 25 * User Dashboard 26 27 = Packages Table Builder = 28 Create beautiful download tables with our visual table builder: 29 * Drag-and-drop column ordering 30 * 20+ data fields (title, categories, download button, file size, etc.) 31 * Multiple fields per column support 32 * Custom column widths and text alignment 33 * DataTable.js integration for sorting and filtering 26 34 27 35 == Installation == … … 31 39 32 40 == Changelog == 41 42 = 2.0.0 - 2025.12.26 = 43 ✅ New visual table builder for Packages Table widget 44 ✅ Drag-and-drop column configuration with Repeater control 45 ✅ Multi-select data fields dropdown (20+ fields available) 46 ✅ Column width and text alignment options per column 47 ✅ Legacy mode toggle for backward compatibility 48 ✅ Added BaseWidget abstract class for all widgets 49 ✅ Added input sanitization for all widget settings 50 ✅ Added dependency check for WPDM and Elementor 51 ✅ Added Composer PSR-4 autoloading support 52 ✅ Added style controls helpers (container, typography) 53 ✅ Added new REST endpoint for category search 54 ✅ Improved REST API security with prepared statements 55 ✅ Improved code organization with proper namespacing 56 🐞 Fixed taxonomy typo in helper functions 57 🐞 Fixed hook timing issues for Elementor and REST API 58 🐞 Fixed categories array handling in Packages Table widget 59 ✅ Updated all widgets to use new BaseWidget class 33 60 34 61 = 1.3.0 - 2025.03.21 = -
wpdm-elementor/trunk/src/Main.php
r2932103 r3427512 1 1 <?php 2 /** 3 * Main plugin class for WPDM Elementor integration. 4 * 5 * @package WPDM\Elementor 6 * @since 1.0.0 7 */ 2 8 3 9 namespace WPDM\Elementor; … … 19 25 use WPDM\Elementor\Widgets\UserProfileWidget; 20 26 27 /** 28 * Class Main 29 * 30 * Handles the initialization and registration of WPDM widgets with Elementor. 31 * Implements the Singleton pattern to ensure only one instance exists. 32 * 33 * @since 1.0.0 34 */ 21 35 final class Main 22 36 { 37 /** 38 * Plugin version. 39 * 40 * @var string 41 */ 42 const VERSION = '2.0.0'; 23 43 24 44 /** 25 * 26 * 45 * Minimum Elementor version required. 46 * 47 * @var string 27 48 */ 28 public static function getInstance() 49 const MINIMUM_ELEMENTOR_VERSION = '3.0.0'; 50 51 /** 52 * Minimum PHP version required. 53 * 54 * @var string 55 */ 56 const MINIMUM_PHP_VERSION = '7.4'; 57 58 /** 59 * Get the singleton instance. 60 * 61 * Ensures only one instance of the class is loaded or can be loaded. 62 * 63 * @since 1.0.0 64 * @return self The singleton instance. 65 */ 66 public static function getInstance(): self 29 67 { 30 68 static $instance; 31 69 if (is_null($instance)) { 32 $instance = new self ;70 $instance = new self(); 33 71 } 34 72 return $instance; … … 36 74 37 75 /** 38 * 39 * 76 * Private constructor to prevent direct instantiation. 77 * 78 * Initializes the API and sets up WordPress hooks. 79 * 80 * @since 1.0.0 40 81 */ 41 82 private function __construct() 42 83 { 43 84 API::getInstance(); 44 add_action("plugin_loaded", [$this, 'pluginLoaded']);45 85 86 // Load text domain 87 load_plugin_textdomain( 88 'wpdm-elementor', 89 false, 90 dirname(plugin_basename(__DIR__)) . '/languages/' 91 ); 92 93 // Register Elementor hooks - check if elementor/init already fired 94 if (did_action('elementor/init')) { 95 $this->addHooks(); 96 } else { 97 add_action('elementor/init', [$this, 'addHooks']); 98 } 46 99 } 47 100 48 function pluginLoaded(){49 load_plugin_textdomain('wpdm-elementor', dirname(__DIR__) . "/languages/", basename(__DIR__).'/languages/');50 add_action( 'elementor/init', [ $this, 'addHooks' ] );51 }52 53 54 101 /** 55 * 56 * 102 * Register Elementor-specific hooks. 103 * 104 * Sets up category and widget registration hooks. 105 * 106 * @since 1.0.0 107 * @return void 57 108 */ 58 function addHooks()109 public function addHooks(): void 59 110 { 60 111 add_action('elementor/elements/categories_registered', [$this, 'registerCategory'], 0); … … 63 114 64 115 /** 65 * 66 * 116 * Register the WPDM widget category. 117 * 118 * Adds a 'Download Manager' category to the Elementor widget panel. 119 * 120 * @since 1.0.0 121 * @param Elements_Manager $elements_manager Elementor elements manager instance. 122 * @return void 67 123 */ 68 public function registerCategory(Elements_Manager $elements Manager)124 public function registerCategory(Elements_Manager $elements_manager): void 69 125 { 70 $elementsManager->add_category('wpdm', ['title' => 'Download Manager']); 126 $elements_manager->add_category( 127 'wpdm', 128 [ 129 'title' => __('Download Manager', WPDM_ELEMENTOR), 130 'icon' => 'eicon-download-button', 131 ] 132 ); 71 133 } 72 134 73 135 /** 74 * 75 * 136 * Register all WPDM widgets with Elementor. 137 * 138 * Includes the widget files and registers each widget class. 139 * 140 * @since 1.0.0 141 * @param Widgets_Manager $widget_manager Elementor widgets manager instance. 142 * @return void 76 143 */ 77 public function registerWidgets(Widgets_Manager $widget_manager) 144 public function registerWidgets(Widgets_Manager $widget_manager): void 78 145 { 146 require_once __DIR__ . '/includes.php'; 79 147 80 require_once __DIR__.'/includes.php'; 148 // Package-related widgets 149 $widget_manager->register(new PackagesWidget()); 150 $widget_manager->register(new PackageWidget()); 151 $widget_manager->register(new CategoryWidget()); 152 $widget_manager->register(new AllPackagesWidget()); 153 $widget_manager->register(new SearchResultWidget()); 154 $widget_manager->register(new DirectLinkWidget()); 81 155 82 83 $widget_manager->register(new PackagesWidget()); 84 85 $widget_manager->register(new PackageWidget()); 86 87 $widget_manager->register(new CategoryWidget()); 88 89 //$widget_manager->register(new TagWidget()); 90 91 $widget_manager->register(new AllPackagesWidget()); 92 93 $widget_manager->register(new SearchResultWidget()); 94 156 // User-related widgets 95 157 $widget_manager->register(new RegFormWidget()); 96 97 158 $widget_manager->register(new LoginFormWidget()); 98 99 159 $widget_manager->register(new FrontendWidget()); 100 101 160 $widget_manager->register(new UserDashboardWidget()); 102 161 103 $widget_manager->register(new DirectLinkWidget()); 104 105 //$widget_manager->register(new UserProfileWidget()); 106 162 // Disabled widgets (uncomment to enable) 163 // $widget_manager->register(new TagWidget()); 164 // $widget_manager->register(new UserProfileWidget()); 107 165 } 108 166 167 /** 168 * Get the plugin version. 169 * 170 * @since 1.3.0 171 * @return string Plugin version. 172 */ 173 public function getVersion(): string 174 { 175 return self::VERSION; 176 } 109 177 } -
wpdm-elementor/trunk/src/api/API.php
r2392526 r3427512 1 1 <?php 2 /** 3 * REST API endpoints for WPDM Elementor integration. 4 * 5 * @package WPDM\Elementor\API 6 * @since 1.0.0 7 */ 2 8 3 9 namespace WPDM\Elementor\API; 4 10 11 use WP_REST_Request; 12 use WP_REST_Response; 5 13 6 14 /** 15 * Class API 16 * 17 * Handles REST API endpoints for the WPDM Elementor integration. 18 * Provides package search functionality for SELECT2 dropdowns. 19 * 20 * @since 1.0.0 21 */ 7 22 class API 8 23 { 24 /** 25 * REST API namespace. 26 * 27 * @var string 28 */ 29 const API_NAMESPACE = 'wpdm-elementor/v1'; 9 30 10 public static function getInstance() 31 /** 32 * Get the singleton instance. 33 * 34 * @since 1.0.0 35 * @return self The singleton instance. 36 */ 37 public static function getInstance(): self 11 38 { 12 39 static $instance; 13 40 if (is_null($instance)) { 14 $instance = new self ;41 $instance = new self(); 15 42 } 16 43 return $instance; 17 44 } 18 45 46 /** 47 * Private constructor. 48 * 49 * Registers the REST API initialization hook. 50 * 51 * @since 1.0.0 52 */ 19 53 private function __construct() 20 54 { 21 add_action('rest_api_init', array($this, 'registerAPIEndpoints')); 55 // Check if rest_api_init already fired 56 if (did_action('rest_api_init')) { 57 $this->registerAPIEndpoints(); 58 } else { 59 add_action('rest_api_init', [$this, 'registerAPIEndpoints']); 60 } 22 61 } 23 62 24 public function registerAPIEndpoints() 63 /** 64 * Register REST API endpoints. 65 * 66 * @since 1.0.0 67 * @return void 68 */ 69 public function registerAPIEndpoints(): void 25 70 { 26 register_rest_route('wpdm-elementor/v1', '/search-packages', [ 27 'methods' => 'GET', 28 'callback' => [$this, 'searchPackages'], 29 'permission_callback' => function () { 30 return true; 31 } 32 ]); 71 register_rest_route( 72 self::API_NAMESPACE, 73 '/search-packages', 74 [ 75 'methods' => 'GET', 76 'callback' => [$this, 'searchPackages'], 77 'permission_callback' => '__return_true', 78 ] 79 ); 80 81 register_rest_route( 82 self::API_NAMESPACE, 83 '/search-categories', 84 [ 85 'methods' => 'GET', 86 'callback' => [$this, 'searchCategories'], 87 'permission_callback' => '__return_true', 88 ] 89 ); 33 90 } 34 91 92 /** 93 * Check if the current user has permission to access the endpoint. 94 * 95 * Returns true as this is a read-only search endpoint 96 * used in Elementor editor context. 97 * 98 * @since 1.0.0 99 * @return bool Always returns true. 100 */ 101 public function checkPermission(): bool 102 { 103 return true; 104 } 35 105 36 public function searchPackages() 106 /** 107 * Search packages by title. 108 * 109 * Returns packages matching the search term for SELECT2 dropdown. 110 * 111 * @since 1.0.0 112 * @param WP_REST_Request $request REST request object. 113 * @return WP_REST_Response JSON response with package results. 114 */ 115 public function searchPackages(WP_REST_Request $request): WP_REST_Response 37 116 { 38 117 global $wpdb; 39 $posts_table = "{$wpdb->prefix}posts"; 118 119 $term = $request->get_param('term'); 40 120 $packages = []; 41 $term = wpdm_query_var('term', ['validate' => 'txt', 'default' => null]);42 121 43 if ($term) { 44 $result_rows = $wpdb->get_results("SELECT ID, post_title FROM $posts_table where `post_type` = 'wpdmpro' AND `post_title` LIKE '%" . $term . "%' "); 45 foreach ($result_rows as $row) { 46 array_push($packages, [ 47 'id' => $row->ID, 48 'text' => $row->post_title 49 ]); 122 if (!empty($term)) { 123 // Use prepared statement for security 124 $like_term = '%' . $wpdb->esc_like($term) . '%'; 125 126 $results = $wpdb->get_results( 127 $wpdb->prepare( 128 "SELECT ID, post_title 129 FROM {$wpdb->posts} 130 WHERE post_type = 'wpdmpro' 131 AND post_status = 'publish' 132 AND post_title LIKE %s 133 ORDER BY post_title ASC 134 LIMIT 20", 135 $like_term 136 ) 137 ); 138 139 if ($results) { 140 foreach ($results as $row) { 141 $packages[] = [ 142 'id' => (int) $row->ID, 143 'text' => esc_html($row->post_title), 144 ]; 145 } 50 146 } 51 147 } 52 //results key is necessary for jquery select2 53 wp_send_json(["results" => $packages]); 148 149 // Results key is required for jQuery SELECT2 150 return new WP_REST_Response(['results' => $packages], 200); 151 } 152 153 /** 154 * Search categories by name. 155 * 156 * Returns categories matching the search term for SELECT2 dropdown. 157 * 158 * @since 1.3.0 159 * @param WP_REST_Request $request REST request object. 160 * @return WP_REST_Response JSON response with category results. 161 */ 162 public function searchCategories(WP_REST_Request $request): WP_REST_Response 163 { 164 $term = $request->get_param('term'); 165 $categories = []; 166 167 $args = [ 168 'taxonomy' => 'wpdmcategory', 169 'hide_empty' => false, 170 'number' => 20, 171 'orderby' => 'name', 172 'order' => 'ASC', 173 ]; 174 175 if (!empty($term)) { 176 $args['search'] = $term; 177 } 178 179 $terms = get_terms($args); 180 181 if (!is_wp_error($terms) && !empty($terms)) { 182 foreach ($terms as $category) { 183 $categories[] = [ 184 'id' => $category->slug, 185 'text' => esc_html($category->name), 186 ]; 187 } 188 } 189 190 return new WP_REST_Response(['results' => $categories], 200); 54 191 } 55 192 } -
wpdm-elementor/trunk/src/constants.php
r2932103 r3427512 1 1 <?php 2 /** 3 * Plugin constants for WPDM Elementor integration. 4 * 5 * @package WPDM\Elementor 6 * @since 1.0.0 7 */ 2 8 3 define('WPDM_ELEMENTOR', 'wpdm-elementor'); 9 if (!defined('ABSPATH')) { 10 exit; 11 } 12 13 /** 14 * Text domain for translations. 15 * 16 * @var string 17 */ 18 if (!defined('WPDM_ELEMENTOR')) { 19 define('WPDM_ELEMENTOR', 'wpdm-elementor'); 20 } 21 22 /** 23 * Plugin version. 24 * 25 * @var string 26 */ 27 if (!defined('WPDM_ELEMENTOR_VERSION')) { 28 define('WPDM_ELEMENTOR_VERSION', '2.0.0'); 29 } 30 31 /** 32 * Plugin directory path. 33 * 34 * @var string 35 */ 36 if (!defined('WPDM_ELEMENTOR_PATH')) { 37 define('WPDM_ELEMENTOR_PATH', dirname(__DIR__) . '/'); 38 } 39 40 /** 41 * Plugin directory URL. 42 * 43 * @var string 44 */ 45 if (!defined('WPDM_ELEMENTOR_URL')) { 46 define('WPDM_ELEMENTOR_URL', plugin_dir_url(dirname(__FILE__))); 47 } -
wpdm-elementor/trunk/src/helper-functions.php
r3077561 r3427512 1 1 <?php 2 /** 3 * Helper functions for WPDM Elementor integration. 4 * 5 * @package WPDM\Elementor 6 * @since 1.0.0 7 */ 2 8 3 /** 4 *5 * @return [template1.php => Template 1] 6 */ 9 if (!defined('ABSPATH')) { 10 exit; 11 } 12 7 13 if (!function_exists('get_wpdm_link_templates')) { 8 function get_wpdm_link_templates() 14 /** 15 * Get WPDM link templates for shortcode usage. 16 * 17 * Returns an array of available link templates with their display names. 18 * Template file extensions (.php) are stripped from the names. 19 * 20 * @since 1.0.0 21 * @return array Associative array of template_file => template_name pairs. 22 */ 23 function get_wpdm_link_templates(): array 9 24 { 25 if (!function_exists('WPDM')) { 26 return []; 27 } 28 10 29 $link_templates = WPDM()->packageTemplate->getTemplates('link'); 11 foreach ($link_templates as &$template) { 12 $template = str_replace(".php", "", $template); 13 } 30 31 if (!is_array($link_templates)) { 32 return []; 33 } 34 35 foreach ($link_templates as &$template) { 36 $template = str_replace('.php', '', $template); 37 } 38 14 39 return $link_templates; 15 40 } 16 41 } 17 42 43 if (!function_exists('get_wpdmcategory_terms')) { 44 /** 45 * Get WPDM category terms for Elementor controls. 46 * 47 * Returns an array of category terms formatted for use in 48 * Elementor SELECT2 controls. 49 * 50 * @since 1.0.0 51 * @return array Associative array of slug => name pairs. 52 */ 53 function get_wpdmcategory_terms(): array 54 { 55 $terms = get_terms([ 56 'taxonomy' => 'wpdmcategory', 57 'hide_empty' => false, 58 ]); 18 59 19 /** 20 * 21 * @return [slug => name] 22 */ 23 if (!function_exists('get_wpdmcategory_terms')) { 24 function get_wpdmcategory_terms() 25 { 26 $wpdmcategory_terms = get_terms(['taxonomoy' => 'wpdmcategory']); 27 foreach ($wpdmcategory_terms as $k => $t) { 28 $wpdmcategory_terms[$t->slug] = $t->name; 29 unset($wpdmcategory_terms[$k]); 30 }; 31 return $wpdmcategory_terms; 60 if (is_wp_error($terms) || empty($terms)) { 61 return []; 62 } 63 64 $options = []; 65 foreach ($terms as $term) { 66 $options[$term->slug] = $term->name; 67 } 68 69 return $options; 32 70 } 33 71 } 34 72 35 if(!function_exists('get_elementor_link_templates')){ 36 function get_elementor_link_templates() 73 if (!function_exists('get_elementor_link_templates')) { 74 /** 75 * Get WPDM link templates formatted for Elementor controls. 76 * 77 * Returns an array of available link templates formatted for 78 * Elementor SELECT2 controls, with file extensions removed. 79 * 80 * @since 1.0.0 81 * @return array Associative array of template_key => template_key pairs. 82 */ 83 function get_elementor_link_templates(): array 37 84 { 85 if (!function_exists('WPDM')) { 86 return []; 87 } 88 38 89 $link_templates = WPDM()->packageTemplate->getTemplates('link'); 39 array_walk($link_templates, function (&$v, $k) {40 $k = strrpos($k, ".") ? substr($k, 0, strrpos($k, ".")) : $k;41 $v = $k;42 });43 90 44 return $link_templates; 91 if (!is_array($link_templates)) { 92 return []; 93 } 94 95 $options = []; 96 foreach ($link_templates as $key => $value) { 97 // Remove file extension from key 98 $clean_key = strrpos($key, '.') !== false 99 ? substr($key, 0, strrpos($key, '.')) 100 : $key; 101 $options[$clean_key] = $clean_key; 102 } 103 104 return $options; 45 105 } 46 106 } 107 108 if (!function_exists('get_wpdm_tag_terms')) { 109 /** 110 * Get WPDM tag terms for Elementor controls. 111 * 112 * Returns an array of tag terms formatted for use in 113 * Elementor SELECT2 controls. 114 * 115 * @since 1.3.0 116 * @return array Associative array of slug => name pairs. 117 */ 118 function get_wpdm_tag_terms(): array 119 { 120 $terms = get_terms([ 121 'taxonomy' => 'wpdmtag', 122 'hide_empty' => false, 123 ]); 124 125 if (is_wp_error($terms) || empty($terms)) { 126 return []; 127 } 128 129 $options = []; 130 foreach ($terms as $term) { 131 $options[$term->slug] = $term->name; 132 } 133 134 return $options; 135 } 136 } -
wpdm-elementor/trunk/src/includes.php
r2392526 r3427512 1 1 <?php 2 2 3 // autoload.php @generated by Composer 3 /** 4 * File includes for WPDM Elementor plugin. 5 * 6 * If Composer autoload is available, use it. 7 * Otherwise, fall back to manual includes. 8 */ 4 9 5 //require_once __DIR__ . '/composer/autoload_real.php';10 $composer_autoload = dirname(__DIR__) . '/vendor/autoload.php'; 6 11 7 //return ComposerAutoloaderInitcb57ad66fbc0e2adc70532ce7d9c8223::getLoader(); 12 if (file_exists($composer_autoload)) { 13 require_once $composer_autoload; 14 } else { 15 // Manual includes (fallback when Composer is not used) 16 include_once dirname(__DIR__) . '/src/constants.php'; 17 include_once dirname(__DIR__) . '/src/helper-functions.php'; 8 18 9 include dirname(__DIR__).'/src/constants.php'; 10 include dirname(__DIR__).'/src/helper-functions.php'; 11 include dirname(__DIR__).'/src/widgets/AllPackagesWidget.php'; 12 include dirname(__DIR__).'/src/widgets/CategoryWidget.php'; 13 include dirname(__DIR__).'/src/widgets/DirectLinkWidget.php'; 14 include dirname(__DIR__).'/src/widgets/FrontendWidget.php'; 15 include dirname(__DIR__).'/src/widgets/LoginFormWidget.php'; 16 include dirname(__DIR__).'/src/widgets/PackagesWidget.php'; 17 include dirname(__DIR__).'/src/widgets/PackageWidget.php'; 18 include dirname(__DIR__).'/src/widgets/RegFormWidget.php'; 19 include dirname(__DIR__).'/src/widgets/SearchResultWidget.php'; 20 include dirname(__DIR__).'/src/widgets/TagWidget.php'; 21 include dirname(__DIR__).'/src/widgets/UserDashboardWidget.php'; 22 include dirname(__DIR__).'/src/widgets/UserProfileWidget.php'; 19 // Base widget class (must be loaded before other widgets) 20 include_once dirname(__DIR__) . '/src/widgets/BaseWidget.php'; 21 22 // Widget classes 23 include_once dirname(__DIR__) . '/src/widgets/AllPackagesWidget.php'; 24 include_once dirname(__DIR__) . '/src/widgets/CategoryWidget.php'; 25 include_once dirname(__DIR__) . '/src/widgets/DirectLinkWidget.php'; 26 include_once dirname(__DIR__) . '/src/widgets/FrontendWidget.php'; 27 include_once dirname(__DIR__) . '/src/widgets/LoginFormWidget.php'; 28 include_once dirname(__DIR__) . '/src/widgets/PackagesWidget.php'; 29 include_once dirname(__DIR__) . '/src/widgets/PackageWidget.php'; 30 include_once dirname(__DIR__) . '/src/widgets/RegFormWidget.php'; 31 include_once dirname(__DIR__) . '/src/widgets/SearchResultWidget.php'; 32 include_once dirname(__DIR__) . '/src/widgets/TagWidget.php'; 33 include_once dirname(__DIR__) . '/src/widgets/UserDashboardWidget.php'; 34 include_once dirname(__DIR__) . '/src/widgets/UserProfileWidget.php'; 35 } 23 36 24 37 -
wpdm-elementor/trunk/src/widgets/AllPackagesWidget.php
r3259585 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 6 7 class AllPackagesWidget extends Widget_Base 5 use Elementor\Controls_Manager; 6 use Elementor\Repeater; 7 8 /** 9 * All Packages Widget. 10 * Displays packages in a table/grid format with customizable columns. 11 */ 12 class AllPackagesWidget extends BaseWidget 8 13 { 14 /** 15 * Expected settings keys for this widget. 16 */ 17 private const SETTINGS_KEYS = [ 18 'categories', 'orderby', 'order', 'items_per_page', 19 'table_columns', 'cols', 'colheads', 'jstable', 'login' 20 ]; 21 22 /** 23 * Settings sanitization rules. 24 */ 25 private const SANITIZERS = [ 26 'orderby' => 'orderby', 27 'order' => 'order', 28 'items_per_page' => 'int', 29 'cols' => 'text', 30 'colheads' => 'text', 31 'jstable' => 'text', 32 'login' => 'text', 33 ]; 34 35 /** 36 * Available WPDM data fields for table columns. 37 * 38 * @return array Field key => label pairs. 39 */ 40 private function getDataFieldOptions(): array 41 { 42 return [ 43 // Basic Info 44 'title' => __('Title', WPDM_ELEMENTOR), 45 'page_link' => __('Title with Link', WPDM_ELEMENTOR), 46 'description' => __('Description', WPDM_ELEMENTOR), 47 'excerpt' => __('Excerpt', WPDM_ELEMENTOR), 48 49 // Taxonomy 50 'categories' => __('Categories', WPDM_ELEMENTOR), 51 'tags' => __('Tags', WPDM_ELEMENTOR), 52 53 // Download 54 'download_link' => __('Download Button', WPDM_ELEMENTOR), 55 'download_url' => __('Download URL', WPDM_ELEMENTOR), 56 'download_count' => __('Download Count', WPDM_ELEMENTOR), 57 58 // File Info 59 'file_size' => __('File Size', WPDM_ELEMENTOR), 60 'file_count' => __('File Count', WPDM_ELEMENTOR), 61 'file_type' => __('File Type', WPDM_ELEMENTOR), 62 'version' => __('Version', WPDM_ELEMENTOR), 63 64 // Dates 65 'publish_date' => __('Publish Date', WPDM_ELEMENTOR), 66 'update_date' => __('Update Date', WPDM_ELEMENTOR), 67 68 // Media 69 'thumb' => __('Thumbnail', WPDM_ELEMENTOR), 70 'preview' => __('Preview', WPDM_ELEMENTOR), 71 'icon' => __('File Icon', WPDM_ELEMENTOR), 72 73 // Author 74 'author' => __('Author Name', WPDM_ELEMENTOR), 75 //'author_pic' => __('Author Picture', WPDM_ELEMENTOR), 76 77 // Stats 78 'view_count' => __('View Count', WPDM_ELEMENTOR), 79 80 ]; 81 } 9 82 10 83 public function get_name() … … 15 88 public function get_title() 16 89 { 17 return 'Packages Table';90 return __('Packages Table', WPDM_ELEMENTOR); 18 91 } 19 92 … … 23 96 } 24 97 25 public function get_ categories()26 { 27 return ['wpdm' ];98 public function get_keywords(): array 99 { 100 return ['wpdm', 'download', 'table', 'packages', 'list', 'grid']; 28 101 } 29 102 30 103 protected function register_controls() 31 104 { 32 105 // Content Section - Query 33 106 $this->start_controls_section( 34 'content_section', 35 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)), 37 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 ] 39 ); 40 41 //categories 107 'query_section', 108 [ 109 'label' => __('Query', WPDM_ELEMENTOR), 110 'tab' => Controls_Manager::TAB_CONTENT, 111 ] 112 ); 113 42 114 $this->add_control( 43 115 'categories', 44 116 [ 45 'label' => esc_attr(__('Categories', WPDM_ELEMENTOR)),46 'type' => \Elementor\Controls_Manager::SELECT2,117 'label' => __('Filter by Categories', WPDM_ELEMENTOR), 118 'type' => Controls_Manager::SELECT2, 47 119 'multiple' => true, 48 'options' => get_wpdmcategory_terms(), 49 'default' => [] 50 ] 51 ); 52 53 54 55 //order by: Select 120 'options' => $this->getCategoryOptions(), 121 'default' => [] 122 ] 123 ); 124 56 125 $this->add_control( 57 126 'orderby', 58 127 [ 59 'label' => esc_attr(__('Order By', WPDM_ELEMENTOR)), 60 'type' => \Elementor\Controls_Manager::SELECT2, 61 'options' => ['date' => 'Date', 'title' => 'Title'], 128 'label' => __('Order By', WPDM_ELEMENTOR), 129 'type' => Controls_Manager::SELECT, 130 'options' => [ 131 'date' => __('Date', WPDM_ELEMENTOR), 132 'title' => __('Title', WPDM_ELEMENTOR), 133 'download_count' => __('Download Count', WPDM_ELEMENTOR), 134 'rand' => __('Random', WPDM_ELEMENTOR), 135 ], 62 136 'default' => 'date', 63 137 ] 64 138 ); 65 139 66 //order: Select67 140 $this->add_control( 68 141 'order', 69 142 [ 70 'label' => esc_attr(__('Order', WPDM_ELEMENTOR)),71 'type' => \Elementor\Controls_Manager::CHOOSE,143 'label' => __('Order', WPDM_ELEMENTOR), 144 'type' => Controls_Manager::CHOOSE, 72 145 'options' => [ 73 'ASC' => ['title' => 'Ascending', 'icon' => 'fa fa-sort-alpha-down'],74 'DESC' => ['title' => 'Descending', 'icon' => 'fa fa-sort-alpha-up']146 'ASC' => ['title' => __('Ascending', WPDM_ELEMENTOR), 'icon' => 'eicon-arrow-up'], 147 'DESC' => ['title' => __('Descending', WPDM_ELEMENTOR), 'icon' => 'eicon-arrow-down'] 75 148 ], 76 149 'default' => 'DESC', 77 'show_label' => false 78 ] 79 ); 80 81 //items per page: text number 150 'toggle' => false 151 ] 152 ); 153 82 154 $this->add_control( 83 155 'items_per_page', 84 156 [ 85 'label' => esc_attr(__('Items Per Page', WPDM_ELEMENTOR)), 86 'type' => \Elementor\Controls_Manager::TEXT, 87 'input_type' => 'number', 88 'default' => '10' 89 ] 90 ); 91 92 93 //cols : text 157 'label' => __('Items Per Page', WPDM_ELEMENTOR), 158 'type' => Controls_Manager::NUMBER, 159 'min' => 1, 160 'max' => 100, 161 'default' => 10 162 ] 163 ); 164 165 $this->end_controls_section(); 166 167 // Content Section - Table Columns 168 $this->start_controls_section( 169 'columns_section', 170 [ 171 'label' => __('Table Columns', WPDM_ELEMENTOR), 172 'tab' => Controls_Manager::TAB_CONTENT, 173 ] 174 ); 175 176 $repeater = new Repeater(); 177 178 $repeater->add_control( 179 'column_heading', 180 [ 181 'label' => __('Column Heading', WPDM_ELEMENTOR), 182 'type' => Controls_Manager::TEXT, 183 'default' => __('Column', WPDM_ELEMENTOR), 184 'label_block' => true, 185 ] 186 ); 187 188 $repeater->add_control( 189 'column_fields', 190 [ 191 'label' => __('Data Fields', WPDM_ELEMENTOR), 192 'type' => Controls_Manager::SELECT2, 193 'multiple' => true, 194 'options' => $this->getDataFieldOptions(), 195 'default' => ['title'], 196 'label_block' => true, 197 'description' => __('Select one or more fields to display in this column', WPDM_ELEMENTOR), 198 ] 199 ); 200 201 $repeater->add_control( 202 'column_width', 203 [ 204 'label' => __('Column Width', WPDM_ELEMENTOR), 205 'type' => Controls_Manager::TEXT, 206 'default' => '', 207 'placeholder' => __('e.g., 100px or 20%', WPDM_ELEMENTOR), 208 'description' => __('Leave empty for auto width', WPDM_ELEMENTOR), 209 ] 210 ); 211 212 $repeater->add_control( 213 'column_align', 214 [ 215 'label' => __('Text Align', WPDM_ELEMENTOR), 216 'type' => Controls_Manager::CHOOSE, 217 'options' => [ 218 'left' => ['title' => __('Left', WPDM_ELEMENTOR), 'icon' => 'eicon-text-align-left'], 219 'center' => ['title' => __('Center', WPDM_ELEMENTOR), 'icon' => 'eicon-text-align-center'], 220 'right' => ['title' => __('Right', WPDM_ELEMENTOR), 'icon' => 'eicon-text-align-right'], 221 ], 222 'default' => 'left', 223 'toggle' => false, 224 ] 225 ); 226 227 $this->add_control( 228 'table_columns', 229 [ 230 'label' => __('Columns', WPDM_ELEMENTOR), 231 'type' => Controls_Manager::REPEATER, 232 'fields' => $repeater->get_controls(), 233 'default' => [ 234 [ 235 'column_heading' => __('Title', WPDM_ELEMENTOR), 236 'column_fields' => ['link'], 237 'column_width' => '', 238 'column_align' => 'left', 239 ], 240 [ 241 'column_heading' => __('Categories', WPDM_ELEMENTOR), 242 'column_fields' => ['categories'], 243 'column_width' => '', 244 'column_align' => 'left', 245 ], 246 [ 247 'column_heading' => __('Download', WPDM_ELEMENTOR), 248 'column_fields' => ['download_link'], 249 'column_width' => '120px', 250 'column_align' => 'center', 251 ], 252 ], 253 'title_field' => '{{{ column_heading }}}', 254 ] 255 ); 256 257 $this->add_control( 258 'legacy_mode_divider', 259 [ 260 'type' => Controls_Manager::DIVIDER, 261 ] 262 ); 263 264 $this->add_control( 265 'use_legacy_mode', 266 [ 267 'label' => __('Use Legacy Mode', WPDM_ELEMENTOR), 268 'type' => Controls_Manager::SWITCHER, 269 'label_on' => __('Yes', WPDM_ELEMENTOR), 270 'label_off' => __('No', WPDM_ELEMENTOR), 271 'return_value' => 'yes', 272 'default' => '', 273 'description' => __('Enable to use the old text-based column configuration', WPDM_ELEMENTOR), 274 ] 275 ); 276 94 277 $this->add_control( 95 278 'cols', 96 279 [ 97 'label' => esc_attr(__('Data field name', WPDM_ELEMENTOR)), 98 'type' => \Elementor\Controls_Manager::TEXT, 99 'input_type' => 'text', 100 'default' => 'title|categories', 101 'description' => 'data field name for each column, column separator |, if you want to show multiple data fields in the same column, data field names should be separated by ,' 102 ] 103 ); 104 105 //cols tab 280 'label' => __('Data Field Names (Legacy)', WPDM_ELEMENTOR), 281 'type' => Controls_Manager::TEXT, 282 'default' => 'title|categories', 283 'description' => __('Column separator: | Multiple fields per column: ,', WPDM_ELEMENTOR), 284 'condition' => [ 285 'use_legacy_mode' => 'yes', 286 ], 287 ] 288 ); 289 106 290 $this->add_control( 107 291 'colheads', 108 292 [ 109 'label' => esc_attr(__('column heading', WPDM_ELEMENTOR)), 110 'type' => \Elementor\Controls_Manager::TEXT, 111 'input_type' => 'text', 112 'default' => 'Title|Categories', 113 'description' => 'colheads="Title|Categories|Update Date::200px|Download::100px' 114 ] 115 ); 116 117 118 //jstable: choose 293 'label' => __('Column Headings (Legacy)', WPDM_ELEMENTOR), 294 'type' => Controls_Manager::TEXT, 295 'default' => 'Title|Categories', 296 'description' => __('e.g: Title|Categories|Download::100px', WPDM_ELEMENTOR), 297 'condition' => [ 298 'use_legacy_mode' => 'yes', 299 ], 300 ] 301 ); 302 303 $this->end_controls_section(); 304 305 // Content Section - Table Options 306 $this->start_controls_section( 307 'options_section', 308 [ 309 'label' => __('Table Options', WPDM_ELEMENTOR), 310 'tab' => Controls_Manager::TAB_CONTENT, 311 ] 312 ); 313 119 314 $this->add_control( 120 315 'jstable', 121 316 [ 122 'label' => esc_attr(__('Enable datatable.js', WPDM_ELEMENTOR)), 123 'type' => \Elementor\Controls_Manager::CHOOSE, 124 'options' => [ 125 '0' => ['title' => 'Disable', 'icon' => 'fa fa-times'], 126 '1' => ['title' => 'Enable', 'icon' => 'fa fa-check'] 127 ], 128 'default' => '0' 129 ] 130 ); 131 132 133 //Require login: choose 317 'label' => __('Enable DataTable.js', WPDM_ELEMENTOR), 318 'type' => Controls_Manager::SWITCHER, 319 'label_on' => __('Yes', WPDM_ELEMENTOR), 320 'label_off' => __('No', WPDM_ELEMENTOR), 321 'return_value' => '1', 322 'default' => '', 323 'description' => __('Adds sorting, searching, and pagination features', WPDM_ELEMENTOR), 324 ] 325 ); 326 134 327 $this->add_control( 135 328 'login', 136 329 [ 137 'label' => esc_attr(__('Require Login', WPDM_ELEMENTOR)), 138 'type' => \Elementor\Controls_Manager::CHOOSE, 139 'options' => [ 140 '0' => ['title' => 'No', 'icon' => 'fa fa-times'], 141 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check'] 142 ], 143 'default' => '0' 144 ] 145 ); 146 147 330 'label' => __('Require Login', WPDM_ELEMENTOR), 331 'type' => Controls_Manager::SWITCHER, 332 'label_on' => __('Yes', WPDM_ELEMENTOR), 333 'label_off' => __('No', WPDM_ELEMENTOR), 334 'return_value' => '1', 335 'default' => '', 336 'description' => __('Only show table to logged-in users', WPDM_ELEMENTOR), 337 ] 338 ); 148 339 149 340 $this->end_controls_section(); 150 341 } 151 342 152 343 /** 344 * Convert repeater columns to legacy format for WPDM shortcode. 345 * 346 * @param array $columns Repeater columns data. 347 * @return array ['cols' => string, 'colheads' => string] 348 */ 349 private function convertColumnsToLegacyFormat(array $columns): array 350 { 351 $cols = []; 352 $colheads = []; 353 354 foreach ($columns as $column) { 355 // Get fields for this column 356 $fields = $column['column_fields'] ?? ['title']; 357 if (!is_array($fields)) { 358 $fields = [$fields]; 359 } 360 $cols[] = implode(',', $fields); 361 362 // Build column heading with optional width 363 $heading = $column['column_heading'] ?? 'Column'; 364 $width = $column['column_width'] ?? ''; 365 366 if (!empty($width)) { 367 $heading .= '::' . $width; 368 } 369 $colheads[] = $heading; 370 } 371 372 return [ 373 'cols' => implode('|', $cols), 374 'colheads' => implode('|', $colheads), 375 ]; 376 } 153 377 154 378 protected function render() 155 379 { 156 157 $settings = $this->get_settings_for_display(); 158 $cus_settings = array_slice($settings, 0, 10); 159 160 $cus_settings['categories'] = implode(",", $cus_settings['categories']); 161 if(trim($cus_settings['categories']) === '') 162 unset($cus_settings['categories']); 163 164 echo WPDM()->package->shortCodes->allPackages($cus_settings); 165 380 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 381 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 382 383 // Convert categories array to comma-separated string 384 if (isset($settings['categories']) && is_array($settings['categories'])) { 385 $settings['categories'] = implode(',', array_map('sanitize_text_field', $settings['categories'])); 386 } 387 388 // Remove empty categories - ensure it's a string before checking 389 $categories = $settings['categories'] ?? ''; 390 if (!is_string($categories) || empty(trim($categories))) { 391 unset($settings['categories']); 392 } 393 394 // Check if using new repeater mode or legacy mode 395 $use_legacy = !empty($settings['use_legacy_mode']) && $settings['use_legacy_mode'] === 'yes'; 396 397 if (!$use_legacy && !empty($settings['table_columns'])) { 398 // Convert repeater data to legacy format for WPDM 399 $converted = $this->convertColumnsToLegacyFormat($settings['table_columns']); 400 $settings['cols'] = $converted['cols']; 401 $settings['colheads'] = $converted['colheads']; 402 } 403 404 // Remove non-shortcode settings 405 unset($settings['table_columns']); 406 unset($settings['use_legacy_mode']); 407 408 // Convert switcher values 409 $settings['jstable'] = !empty($settings['jstable']) ? '1' : '0'; 410 $settings['login'] = !empty($settings['login']) ? '1' : '0'; 411 412 echo WPDM()->package->shortCodes->allPackages($settings); 166 413 } 167 414 } -
wpdm-elementor/trunk/src/widgets/CategoryWidget.php
r3259585 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 6 7 class CategoryWidget extends Widget_Base 5 /** 6 * Category Widget. 7 * Displays packages filtered by category. 8 */ 9 class CategoryWidget extends BaseWidget 8 10 { 11 /** 12 * Expected settings keys for this widget. 13 */ 14 private const SETTINGS_KEYS = [ 15 'catid', 'operator', 'title', 'desc', 'items_per_page', 16 'orderby', 'order', 'template', 'author', 17 'cols', 'colspad', 'colsphone', 'toolbar', 'paging' 18 ]; 19 20 /** 21 * Settings sanitization rules. 22 */ 23 private const SANITIZERS = [ 24 'operator' => 'text', 25 'title' => 'text', 26 'desc' => 'text', 27 'items_per_page' => 'int', 28 'orderby' => 'orderby', 29 'order' => 'order', 30 'template' => 'text', 31 'author' => 'text', 32 'cols' => 'int', 33 'colspad' => 'int', 34 'colsphone' => 'int', 35 'toolbar' => 'text', 36 'paging' => 'text', 37 ]; 9 38 10 39 public function get_name() … … 15 44 public function get_title() 16 45 { 17 return 'Packages By Category';46 return __('Packages By Category', WPDM_ELEMENTOR); 18 47 } 19 48 … … 23 52 } 24 53 25 public function get_categories()26 {27 return ['wpdm'];28 }29 30 54 protected function register_controls() 31 55 { 32 33 56 $this->start_controls_section( 34 57 'content_section', 35 58 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)),59 'label' => __('Parameters', WPDM_ELEMENTOR), 37 60 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 61 ] 39 62 ); 40 63 41 42 //categories: multi select43 64 $this->add_control( 44 65 'catid', 45 66 [ 46 'label' => esc_attr(__('Include Categories', WPDM_ELEMENTOR)),67 'label' => __('Include Categories', WPDM_ELEMENTOR), 47 68 'type' => \Elementor\Controls_Manager::SELECT2, 48 69 'multiple' => true, 49 'options' => get_wpdmcategory_terms(),70 'options' => $this->getCategoryOptions(), 50 71 'default' => [] 51 72 ] 52 73 ); 53 74 54 //Operator: Choose55 75 $this->add_control( 56 76 'operator', 57 77 [ 58 'label' => esc_attr(__('Operator', WPDM_ELEMENTOR)), 59 'type' => \Elementor\Controls_Manager::SELECT2, 60 'options' => ['IN' => 'IN', 'NOT IN' => 'NOT IN', 'AND' => 'AND', 'EXISTS' => 'EXISTS', 'NOT EXISTS' => 'NOT EXISTS'], 78 'label' => __('Operator', WPDM_ELEMENTOR), 79 'type' => \Elementor\Controls_Manager::SELECT2, 80 'options' => [ 81 'IN' => 'IN', 82 'NOT IN' => 'NOT IN', 83 'AND' => 'AND', 84 'EXISTS' => 'EXISTS', 85 'NOT EXISTS' => 'NOT EXISTS' 86 ], 61 87 'default' => 'IN', 62 'description' => esc_attr(__("Use this parameter only when you are using multiple categories.", WPDM_ELEMENTOR)) 63 ] 64 ); 65 66 //title: Text 88 'description' => __('Use this parameter only when using multiple categories.', WPDM_ELEMENTOR) 89 ] 90 ); 91 67 92 $this->add_control( 68 93 'title', 69 94 [ 70 'label' => esc_attr(__('Title', WPDM_ELEMENTOR)),95 'label' => __('Title', WPDM_ELEMENTOR), 71 96 'type' => \Elementor\Controls_Manager::TEXT, 72 97 'input_type' => 'text', 73 'description' => esc_attr(__('You can use any text there, if you use “1” then it will show the category title', WPDM_ELEMENTOR)),98 'description' => __('Use "1" to show category title, or enter custom text', WPDM_ELEMENTOR), 74 99 'default' => '1' 75 100 ] 76 101 ); 77 102 78 //description: Text79 103 $this->add_control( 80 104 'desc', 81 105 [ 82 'label' => esc_attr(__('Description', WPDM_ELEMENTOR)),106 'label' => __('Description', WPDM_ELEMENTOR), 83 107 'type' => \Elementor\Controls_Manager::TEXT, 84 108 'input_type' => 'text', 85 'description' => esc_attr(__('You can use any text there, if you use “1” then it will show the category description', WPDM_ELEMENTOR)),109 'description' => __('Use "1" to show category description, or enter custom text', WPDM_ELEMENTOR), 86 110 'default' => '1' 87 88 ] 89 ); 90 91 //items per page: text number 111 ] 112 ); 113 92 114 $this->add_control( 93 115 'items_per_page', 94 116 [ 95 'label' => esc_attr(__('Items Per Page', WPDM_ELEMENTOR)), 96 'type' => \Elementor\Controls_Manager::TEXT, 97 'input_type' => 'number', 98 'default' => '10' 99 ] 100 ); 101 102 103 //order by: Select 117 'label' => __('Items Per Page', WPDM_ELEMENTOR), 118 'type' => \Elementor\Controls_Manager::NUMBER, 119 'min' => 1, 120 'max' => 100, 121 'default' => 10 122 ] 123 ); 124 104 125 $this->add_control( 105 126 'orderby', 106 127 [ 107 'label' => esc_attr(__('Order By', WPDM_ELEMENTOR)),108 'type' => \Elementor\Controls_Manager::SELECT2, 109 'options' => ['date' => 'Date', 'title' => 'Title'],128 'label' => __('Order By', WPDM_ELEMENTOR), 129 'type' => \Elementor\Controls_Manager::SELECT2, 130 'options' => ['date' => __('Date', WPDM_ELEMENTOR), 'title' => __('Title', WPDM_ELEMENTOR)], 110 131 'default' => 'date', 111 132 ] 112 133 ); 113 134 114 //order: Choose115 135 $this->add_control( 116 136 'order', 117 137 [ 118 'label' => esc_attr(__('Order', WPDM_ELEMENTOR)),138 'label' => __('Order', WPDM_ELEMENTOR), 119 139 'type' => \Elementor\Controls_Manager::CHOOSE, 120 140 'options' => [ 121 'ASC' => ['title' => 'Ascending', 'icon' => 'fa fa-sort-alpha-down'],122 'DESC' => ['title' => 'Descending', 'icon' => 'fa fa-sort-alpha-up']141 'ASC' => ['title' => __('Ascending', WPDM_ELEMENTOR), 'icon' => 'eicon-arrow-up'], 142 'DESC' => ['title' => __('Descending', WPDM_ELEMENTOR), 'icon' => 'eicon-arrow-down'] 123 143 ], 124 144 'default' => 'DESC', 125 'show_label' => false 126 ] 127 ); 128 129 130 //link template: select 145 'toggle' => false 146 ] 147 ); 131 148 132 149 $this->add_control( 133 150 'template', 134 151 [ 135 'label' => esc_attr(__('Link Template', WPDM_ELEMENTOR)),136 'type' => \Elementor\Controls_Manager::SELECT2, 137 'options' => get_elementor_link_templates(),152 'label' => __('Link Template', WPDM_ELEMENTOR), 153 'type' => \Elementor\Controls_Manager::SELECT2, 154 'options' => $this->getLinkTemplateOptions(), 138 155 'default' => 'link-template-default' 139 156 ] 140 157 ); 141 158 142 143 //authors: Text144 159 $this->add_control( 145 160 'author', 146 161 [ 147 'label' => esc_attr(__('Authors', WPDM_ELEMENTOR)),162 'label' => __('Authors', WPDM_ELEMENTOR), 148 163 'type' => \Elementor\Controls_Manager::TEXT, 149 164 'input_type' => 'text', 150 'placeholder' => esc_attr(__('e.g: 1, 2, 3', WPDM_ELEMENTOR)), 151 'description' => esc_attr(__('Author IDs seperated by comma', WPDM_ELEMENTOR)) 152 ] 153 ); 154 155 //cols web 165 'placeholder' => __('e.g: 1, 2, 3', WPDM_ELEMENTOR), 166 'description' => __('Author IDs separated by comma', WPDM_ELEMENTOR) 167 ] 168 ); 169 156 170 $this->add_control( 157 171 'cols', 158 172 [ 159 'label' => esc_attr(__('Columns In PC', WPDM_ELEMENTOR)),160 'type' => \Elementor\Controls_Manager:: TEXT,161 ' input_type' => 'number',162 ' default' => '3'163 ]164 );165 166 //cols tab 173 'label' => __('Columns (Desktop)', WPDM_ELEMENTOR), 174 'type' => \Elementor\Controls_Manager::NUMBER, 175 'min' => 1, 176 'max' => 6, 177 'default' => 3 178 ] 179 ); 180 167 181 $this->add_control( 168 182 'colspad', 169 183 [ 170 'label' => esc_attr(__('Columns In Tab', WPDM_ELEMENTOR)),171 'type' => \Elementor\Controls_Manager:: TEXT,172 ' input_type' => 'number',173 ' default' => '2'174 ]175 );176 177 //cols phone 184 'label' => __('Columns (Tablet)', WPDM_ELEMENTOR), 185 'type' => \Elementor\Controls_Manager::NUMBER, 186 'min' => 1, 187 'max' => 4, 188 'default' => 2 189 ] 190 ); 191 178 192 $this->add_control( 179 193 'colsphone', 180 194 [ 181 'label' => esc_attr(__('Columns In Phone', WPDM_ELEMENTOR)),182 'type' => \Elementor\Controls_Manager:: TEXT,183 ' input_type' => 'number',184 ' default' => '1'185 ]186 );187 188 //Show Toolbar: radio 195 'label' => __('Columns (Phone)', WPDM_ELEMENTOR), 196 'type' => \Elementor\Controls_Manager::NUMBER, 197 'min' => 1, 198 'max' => 2, 199 'default' => 1 200 ] 201 ); 202 189 203 $this->add_control( 190 204 'toolbar', 191 205 [ 192 'label' => esc_attr(__('Show Toolbar', WPDM_ELEMENTOR)),206 'label' => __('Show Toolbar', WPDM_ELEMENTOR), 193 207 'type' => \Elementor\Controls_Manager::CHOOSE, 194 208 'options' => [ 195 '1' => ['title' => 'Show', 'icon' => 'fa fa-check'],196 '0' => ['title' => 'Hide', 'icon' => 'fa fa-times']209 '1' => ['title' => __('Show', WPDM_ELEMENTOR), 'icon' => 'eicon-check'], 210 '0' => ['title' => __('Hide', WPDM_ELEMENTOR), 'icon' => 'eicon-close'] 197 211 ], 198 212 'default' => '1', … … 200 214 ); 201 215 202 //show pagination: radio203 216 $this->add_control( 204 217 'paging', 205 218 [ 206 'label' => esc_attr(__('Paging', WPDM_ELEMENTOR)),219 'label' => __('Pagination', WPDM_ELEMENTOR), 207 220 'type' => \Elementor\Controls_Manager::CHOOSE, 208 221 'options' => [ 209 '1' => ['title' => 'Show', 'icon' => 'fa fa-check'],210 '0' => ['title' => 'Hide', 'icon' => 'fa fa-times']222 '1' => ['title' => __('Show', WPDM_ELEMENTOR), 'icon' => 'eicon-check'], 223 '0' => ['title' => __('Hide', WPDM_ELEMENTOR), 'icon' => 'eicon-close'] 211 224 ], 212 225 'default' => '0', … … 214 227 ); 215 228 216 217 229 $this->end_controls_section(); 218 230 } 219 231 220 221 222 232 protected function render() 223 233 { 224 225 $settings = $this->get_settings_for_display(); 226 $cus_settings = array_slice($settings, 0, 15); 227 228 if(!isset($cus_settings['catid'])) return ""; 229 230 $cus_settings['id'] = is_array($cus_settings['catid']) ? implode(",", $cus_settings['catid']) : $cus_settings['catid']; 231 232 echo WPDM()->categories->shortcode->listPackages($cus_settings); 233 234 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 235 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 236 237 if (empty($settings['catid'])) { 238 return; 239 } 240 241 // Convert catid array to comma-separated id 242 $settings['id'] = is_array($settings['catid']) 243 ? implode(',', array_map('sanitize_text_field', $settings['catid'])) 244 : sanitize_text_field($settings['catid']); 245 246 unset($settings['catid']); 247 248 echo WPDM()->categories->shortcode->listPackages($settings); 234 249 } 235 250 } -
wpdm-elementor/trunk/src/widgets/DirectLinkWidget.php
r2844275 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 5 /** 6 * Direct Link Widget. 7 * Creates a direct download link for a package. 8 */ 9 class DirectLinkWidget extends BaseWidget 10 { 11 /** 12 * Expected settings keys for this widget. 13 */ 14 private const SETTINGS_KEYS = ['pid', 'target', 'label', 'class', 'eid', 'style']; 6 15 7 class DirectLinkWidget extends Widget_Base 8 { 16 /** 17 * Settings sanitization rules. 18 */ 19 private const SANITIZERS = [ 20 'pid' => 'int', 21 'target' => 'text', 22 'label' => 'text', 23 'class' => 'css_class', 24 'eid' => 'text', 25 'style' => 'css_style', 26 ]; 9 27 10 public function get_name()11 {12 return 'wpdmdirectlink';13 }28 public function get_name() 29 { 30 return 'wpdmdirectlink'; 31 } 14 32 15 public function get_title()16 {17 return 'Direct download link';18 }33 public function get_title() 34 { 35 return __('Direct download link', WPDM_ELEMENTOR); 36 } 19 37 20 public function get_icon()21 {22 return 'eicon-editor-link';23 }38 public function get_icon() 39 { 40 return 'eicon-editor-link'; 41 } 24 42 25 public function get_categories() 26 { 27 return ['wpdm']; 28 } 43 protected function register_controls() 44 { 45 $this->start_controls_section( 46 'content_section', 47 [ 48 'label' => __('Parameters', WPDM_ELEMENTOR), 49 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 50 ] 51 ); 29 52 30 protected function register_controls() 31 { 53 $this->add_control( 54 'pid', 55 [ 56 'label' => __('Package', WPDM_ELEMENTOR), 57 'type' => \Elementor\Controls_Manager::SELECT2, 58 'placeholder' => __('Package', WPDM_ELEMENTOR), 59 'select2options' => $this->getPackageSearchConfig() 60 ] 61 ); 32 62 33 $this->start_controls_section( 34 'content_section', 35 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)), 37 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 ] 39 ); 63 $this->add_control( 64 'target', 65 [ 66 'label' => __('Link Target', WPDM_ELEMENTOR), 67 'type' => \Elementor\Controls_Manager::SELECT2, 68 'options' => ['_blank' => '_blank', '_self' => '_self'], 69 'default' => '_blank' 70 ] 71 ); 40 72 41 //Package: Text 42 $this->add_control( 43 'pid', 44 [ 45 'label' => esc_attr(__('Package', WPDM_ELEMENTOR)), 46 'type' => \Elementor\Controls_Manager::SELECT2, 47 'placeholder' => esc_attr(__('Package', WPDM_ELEMENTOR)), 48 'select2options' => [ 49 'placeholder' => 'Type Package title', 50 'ajax' => [ 51 'url' => get_rest_url(null, 'wpdm-elementor/v1/search-packages'), 52 'dataType' => 'json', 53 'delay' => 250 54 ], 55 'minimumInputLength' => 2 56 ] 57 ] 58 ); 73 $this->add_control( 74 'label', 75 [ 76 'label' => __('Download link label', WPDM_ELEMENTOR), 77 'type' => \Elementor\Controls_Manager::TEXT, 78 'input_type' => 'text', 79 'default' => 'Download', 80 'placeholder' => __('Download', WPDM_ELEMENTOR), 81 ] 82 ); 59 83 60 //link template: select 61 $this->add_control( 62 'target', 63 [ 64 'label' => esc_attr(__('Link Template', WPDM_ELEMENTOR)), 65 'type' => \Elementor\Controls_Manager::SELECT2, 66 'options' => ['_blank' => '_blank', '_self' => '_self'], 67 'default' => '_blank' 68 ] 69 ); 84 $this->add_control( 85 'class', 86 [ 87 'label' => __('CSS class name', WPDM_ELEMENTOR), 88 'type' => \Elementor\Controls_Manager::TEXT, 89 'input_type' => 'text', 90 ] 91 ); 70 92 71 //label Download link label 72 $this->add_control( 73 'label', 74 [ 75 'label' => esc_attr(__('Download link label', WPDM_ELEMENTOR)), 76 'type' => \Elementor\Controls_Manager::TEXT, 77 'input_type' => 'text', 78 'default' => 'Download', 79 'placeholder' => esc_attr(__('Download', WPDM_ELEMENTOR)), 80 ] 81 ); 93 $this->add_control( 94 'eid', 95 [ 96 'label' => __('HTML element ID', WPDM_ELEMENTOR), 97 'type' => \Elementor\Controls_Manager::TEXT, 98 'input_type' => 'text', 99 ] 100 ); 82 101 83 //class CSS class name, in case you want to apply some css style 84 $this->add_control( 85 'class', 86 [ 87 'label' => esc_attr(__('CSS class name', WPDM_ELEMENTOR)),88 'type' => \Elementor\Controls_Manager::TEXT,89 'input_type' => 'text',90 ]91 );102 $this->add_control( 103 'style', 104 [ 105 'label' => __('CSS Style', WPDM_ELEMENTOR), 106 'type' => \Elementor\Controls_Manager::TEXTAREA, 107 'rows' => 5, 108 'placeholder' => __('e.g., color: #3399ff;', WPDM_ELEMENTOR), 109 ] 110 ); 92 111 112 $this->end_controls_section(); 113 } 93 114 94 //eid HTML element ID 95 $this->add_control( 96 'eid', 97 [ 98 'label' => esc_attr(__('HTML element ID', WPDM_ELEMENTOR)), 99 'type' => \Elementor\Controls_Manager::TEXT, 100 'input_type' => 'text', 101 ] 102 ); 115 protected function render() 116 { 117 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 118 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 103 119 104 //style Apple raw css code ( ex: style="color: #3399ff;" ) 105 $this->add_control( 106 'style', 107 [ 108 'label' => esc_attr(__('CSS Style', WPDM_ELEMENTOR)), 109 'type' => \Elementor\Controls_Manager::TEXTAREA, 110 'rows' => 10, 111 'placeholder' => esc_attr(__('Apple raw css code', WPDM_ELEMENTOR)), 112 ] 113 ); 120 if (empty($settings['pid'])) { 121 return; 122 } 114 123 124 // Map pid to id for WPDM shortcode 125 $settings['id'] = $settings['pid']; 126 unset($settings['pid']); 115 127 116 117 $this->end_controls_section(); 118 } 119 120 121 122 protected function render() 123 { 124 125 $settings = $this->get_settings_for_display(); 126 $cus_settings = array_slice($settings, 0, 8); 127 128 echo '<div class="oembed-elementor-widget">'; 129 // p($cus_settings); 130 $cus_settings['id'] = $cus_settings['pid']; 131 echo WPDM()->package->shortCodes->directLink($cus_settings); 132 133 echo '</div>'; 134 } 128 echo $this->wrapOutput( 129 WPDM()->package->shortCodes->directLink($settings), 130 'direct-link-widget' 131 ); 132 } 135 133 } -
wpdm-elementor/trunk/src/widgets/FrontendWidget.php
r2844275 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 5 /** 6 * Frontend/Author Dashboard Widget. 7 * Displays author/contributor dashboard. 8 */ 9 class FrontendWidget extends BaseWidget 10 { 11 /** 12 * Expected settings keys for this widget. 13 */ 14 private const SETTINGS_KEYS = ['logo', 'flaturl', 'hide']; 6 15 7 class FrontendWidget extends Widget_Base 8 { 16 /** 17 * Settings sanitization rules. 18 */ 19 private const SANITIZERS = [ 20 'logo' => 'url', 21 'flaturl' => 'text', 22 ]; 9 23 10 24 public function get_name() … … 15 29 public function get_title() 16 30 { 17 return 'Author Dashboard';31 return __('Author Dashboard', WPDM_ELEMENTOR); 18 32 } 19 33 … … 23 37 } 24 38 25 public function get_categories()26 {27 return ['wpdm'];28 }29 30 39 protected function register_controls() 31 40 { 32 33 41 $this->start_controls_section( 34 42 'content_section', 35 43 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)),44 'label' => __('Parameters', WPDM_ELEMENTOR), 37 45 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 46 ] 39 47 ); 40 48 41 42 //logo optional, add the logo or any image URL you want to show on top of the login form43 49 $this->add_control( 44 50 'logo', 45 51 [ 46 'label' => esc_attr(__('Logo URL', WPDM_ELEMENTOR)),52 'label' => __('Logo URL', WPDM_ELEMENTOR), 47 53 'type' => \Elementor\Controls_Manager::TEXT, 48 54 'input_type' => 'url', 49 'placeholder' => esc_attr(__('Logo Url', WPDM_ELEMENTOR)),50 'description' => 'optional, add the logo or any image URL you want to show on top of the login form'55 'placeholder' => __('Logo URL', WPDM_ELEMENTOR), 56 'description' => __('Image URL to show on top of the dashboard', WPDM_ELEMENTOR) 51 57 ] 52 58 ); 53 59 54 55 //flaturl Optional parameter, default value 0, use flaturl=1 for flat url56 60 $this->add_control( 57 61 'flaturl', 58 62 [ 59 'label' => esc_attr(__('Flat Url', WPDM_ELEMENTOR)),63 'label' => __('Flat URL', WPDM_ELEMENTOR), 60 64 'type' => \Elementor\Controls_Manager::CHOOSE, 61 65 'options' => [ 62 '0' => ['title' => 'No', 'icon' => 'fa fa-times'],63 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check']66 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 67 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 64 68 ], 65 69 'default' => '0' … … 67 71 ); 68 72 69 //hide70 73 $this->add_control( 71 74 'hide', 72 75 [ 73 'label' => esc_attr(__('hide', WPDM_ELEMENTOR)),76 'label' => __('Hide Elements', WPDM_ELEMENTOR), 74 77 'type' => \Elementor\Controls_Manager::SELECT2, 75 78 'multiple' => true, 76 'options' => ['settings' => 'Settings', 'images' => 'Images', 'cats' => 'Categories', 'tags' => 'Tags'], 79 'options' => [ 80 'settings' => __('Settings', WPDM_ELEMENTOR), 81 'images' => __('Images', WPDM_ELEMENTOR), 82 'cats' => __('Categories', WPDM_ELEMENTOR), 83 'tags' => __('Tags', WPDM_ELEMENTOR) 84 ], 77 85 'default' => [] 78 86 ] 79 87 ); 80 88 81 82 89 $this->end_controls_section(); 83 90 } 84 91 85 86 87 92 protected function render() 88 93 { 94 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 95 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 89 96 90 $settings = $this->get_settings_for_display(); 91 $cus_settings = array_slice($settings, 0, 4); 92 $cus_settings['hide'] = implode(',', $cus_settings['hide']); 97 // Convert hide array to comma-separated string 98 if (!empty($settings['hide']) && is_array($settings['hide'])) { 99 $settings['hide'] = implode(',', array_map('sanitize_text_field', $settings['hide'])); 100 } 93 101 94 echo '<div class="oembed-elementor-widget">'; 95 // p($cus_settings); 96 echo WPDM()->authorDashboard->dashboard($cus_settings); 97 98 echo '</div>'; 102 echo $this->wrapOutput( 103 WPDM()->authorDashboard->dashboard($settings), 104 'author-dashboard-widget' 105 ); 99 106 } 100 107 } -
wpdm-elementor/trunk/src/widgets/LoginFormWidget.php
r2844275 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 5 /** 6 * Login Form Widget. 7 * Displays a user login form. 8 */ 9 class LoginFormWidget extends BaseWidget 10 { 11 /** 12 * Expected settings keys for this widget. 13 */ 14 private const SETTINGS_KEYS = ['redirect', 'logo', 'regurl', 'note_before', 'note_after']; 6 15 7 class LoginFormWidget extends Widget_Base 8 { 16 /** 17 * Settings sanitization rules. 18 */ 19 private const SANITIZERS = [ 20 'redirect' => 'url', 21 'logo' => 'url', 22 'regurl' => 'url', 23 'note_before' => 'html', 24 'note_after' => 'html', 25 ]; 9 26 10 27 public function get_name() … … 15 32 public function get_title() 16 33 { 17 return 'Login Form';34 return __('Login Form', WPDM_ELEMENTOR); 18 35 } 19 36 … … 23 40 } 24 41 25 public function get_categories()26 {27 return ['wpdm'];28 }29 30 42 protected function register_controls() 31 43 { … … 33 45 'content_section', 34 46 [ 35 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)),47 'label' => __('Parameters', WPDM_ELEMENTOR), 36 48 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 37 49 ] 38 50 ); 39 51 40 41 //redirect: optional, use an URL where you want users to redirect after login42 52 $this->add_control( 43 53 'redirect', 44 54 [ 45 'label' => esc_attr(__('Redirect URL', WPDM_ELEMENTOR)),55 'label' => __('Redirect URL', WPDM_ELEMENTOR), 46 56 'type' => \Elementor\Controls_Manager::TEXT, 47 57 'input_type' => 'url', 48 'placeholder' => esc_attr(__('Redirect Url', WPDM_ELEMENTOR)),49 'description' => 'optional, use an URL where you want users to redirect after login'58 'placeholder' => __('Redirect URL', WPDM_ELEMENTOR), 59 'description' => __('URL to redirect after login', WPDM_ELEMENTOR) 50 60 ] 51 61 ); 52 62 53 54 //logo: optional, add the logo or any image URL you want to show on top of the login form55 63 $this->add_control( 56 64 'logo', 57 65 [ 58 'label' => esc_attr(__('Logo URL', WPDM_ELEMENTOR)),66 'label' => __('Logo URL', WPDM_ELEMENTOR), 59 67 'type' => \Elementor\Controls_Manager::TEXT, 60 68 'input_type' => 'url', 61 'placeholder' => esc_attr(__('Logo Url', WPDM_ELEMENTOR)),62 'description' => 'optional, add the logo or any image URL you want to show on top of the login form'69 'placeholder' => __('Logo URL', WPDM_ELEMENTOR), 70 'description' => __('Image URL to show on top of the form', WPDM_ELEMENTOR) 63 71 ] 64 72 ); 65 73 66 67 //regurl: optional, in case, if you have multiple login pages and multiple signup page, you may mention the signup page URL for this login form. Otherwise, it will use the standard signup page URL.68 74 $this->add_control( 69 75 'regurl', 70 76 [ 71 'label' => esc_attr(__("Registration URL", WPDM_ELEMENTOR)),77 'label' => __('Registration URL', WPDM_ELEMENTOR), 72 78 'type' => \Elementor\Controls_Manager::TEXT, 73 79 'input_type' => 'url', 74 'placeholder' => esc_attr(__('Logo Url', WPDM_ELEMENTOR)),75 'description' => 'optional, in case, if you have multiple login pages and multiple signup page, you may mention the signup page URL for this login form. Otherwise, it will use the standard signup page URL.'80 'placeholder' => __('Registration URL', WPDM_ELEMENTOR), 81 'description' => __('Custom signup page URL for this login form', WPDM_ELEMENTOR) 76 82 ] 77 83 ); 78 84 79 //note_before: optional, text/note to show above the login form80 85 $this->add_control( 81 86 'note_before', 82 87 [ 83 'label' => esc_attr(__("Note Before", WPDM_ELEMENTOR)), 84 'type' => \Elementor\Controls_Manager::TEXT, 85 'input_type' => 'text', 86 'placeholder' => esc_attr(__('Note before', WPDM_ELEMENTOR)), 87 'description' => 'optional, text/note to show above the login form' 88 'label' => __('Note Before', WPDM_ELEMENTOR), 89 'type' => \Elementor\Controls_Manager::TEXTAREA, 90 'rows' => 3, 91 'placeholder' => __('Text to show above the form', WPDM_ELEMENTOR), 88 92 ] 89 93 ); 90 94 91 // note_after: optional, text/note to show below the login form92 95 $this->add_control( 93 96 'note_after', 94 97 [ 95 'label' => esc_attr(__("Note After", WPDM_ELEMENTOR)), 96 'type' => \Elementor\Controls_Manager::TEXT, 97 'input_type' => 'text', 98 'placeholder' => esc_attr(__('Note After', WPDM_ELEMENTOR)), 99 'description' => 'optional, text/note to show below the login form' 98 'label' => __('Note After', WPDM_ELEMENTOR), 99 'type' => \Elementor\Controls_Manager::TEXTAREA, 100 'rows' => 3, 101 'placeholder' => __('Text to show below the form', WPDM_ELEMENTOR), 100 102 ] 101 103 ); 102 103 104 104 105 $this->end_controls_section(); 105 106 } 106 107 107 108 109 108 protected function render() 110 109 { 110 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 111 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 111 112 112 $settings = $this->get_settings_for_display(); 113 $cus_settings = array_slice($settings, 0, 5); 114 115 echo '<div class="oembed-elementor-widget">'; 116 // p($cus_settings); 117 echo WPDM()->user->login->form($cus_settings); 118 119 echo '</div>'; 113 echo $this->wrapOutput( 114 WPDM()->user->login->form($settings), 115 'login-form-widget' 116 ); 120 117 } 121 118 } -
wpdm-elementor/trunk/src/widgets/PackageWidget.php
r3077561 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 6 7 class PackageWidget extends Widget_Base { 5 /** 6 * Single Package Widget. 7 * Embeds a single WPDM package. 8 */ 9 class PackageWidget extends BaseWidget 10 { 11 /** 12 * Expected settings keys for this widget. 13 */ 14 private const SETTINGS_KEYS = ['pid', 'ltemplate']; 8 15 9 16 /** 10 * Get widget name. 11 * 12 * Retrieve oEmbed widget name. 13 * 14 * @since 1.0.0 15 * @access public 16 * 17 * @return string Widget name. 17 * Settings sanitization rules. 18 18 */ 19 public function get_name() { 19 private const SANITIZERS = [ 20 'pid' => 'int', 21 'ltemplate' => 'text', 22 ]; 23 24 public function get_name() 25 { 20 26 return 'wpdmpackage'; 21 27 } 22 28 23 /** 24 * Get widget title. 25 * 26 * Retrieve oEmbed widget title. 27 * 28 * @since 1.0.0 29 * @access public 30 * 31 * @return string Widget title. 32 */ 33 public function get_title() { 34 return __( 'Package', 'plugin-name' ); 29 public function get_title() 30 { 31 return __('Package', WPDM_ELEMENTOR); 35 32 } 36 33 37 /** 38 * Get widget icon. 39 * 40 * Retrieve oEmbed widget icon. 41 * 42 * @since 1.0.0 43 * @access public 44 * 45 * @return string Widget icon. 46 */ 47 public function get_icon() { 34 public function get_icon() 35 { 48 36 return 'eicon-download-button'; 49 37 } 50 38 51 /** 52 * Get widget categories. 53 * 54 * Retrieve the list of categories the oEmbed widget belongs to. 55 * 56 * @since 1.0.0 57 * @access public 58 * 59 * @return array Widget categories. 60 */ 61 public function get_categories() { 62 return [ 'wpdm' ]; 63 } 64 65 /** 66 * Register oEmbed widget controls. 67 * 68 * Adds different input fields to allow the user to change and customize the widget settings. 69 * 70 * @since 1.0.0 71 * @access protected 72 */ 73 protected function register_controls() { 74 39 protected function register_controls() 40 { 75 41 $this->start_controls_section( 76 42 'content_section', 77 43 [ 78 'label' => __( 'Parameters', 'plugin-name'),44 'label' => __('Parameters', WPDM_ELEMENTOR), 79 45 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 80 46 ] 81 47 ); 82 48 83 /* $this->add_control(84 'url',85 [86 'label' => __( 'URL to embed', 'plugin-name' ),87 'type' => \Elementor\Controls_Manager::TEXT,88 'input_type' => 'url',89 'placeholder' => __( 'https://your-link.com', 'plugin-name' ),90 ]91 );*/92 93 //package ID: Text94 49 $this->add_control( 95 50 'pid', 96 51 [ 97 'label' => esc_attr(__('Package', WPDM_ELEMENTOR)),52 'label' => __('Package', WPDM_ELEMENTOR), 98 53 'type' => \Elementor\Controls_Manager::SELECT2, 99 'placeholder' => esc_attr(__('Package', WPDM_ELEMENTOR)), 100 'select2options' => [ 101 'placeholder' => 'Type Package title', 102 'ajax' => [ 103 'url' => get_rest_url(null, 'wpdm-elementor/v1/search-packages'), 104 'dataType' => 'json', 105 'delay' => 250 106 ], 107 'minimumInputLength' => 2 108 ] 54 'placeholder' => __('Package', WPDM_ELEMENTOR), 55 'select2options' => $this->getPackageSearchConfig() 109 56 ] 110 57 ); 111 58 112 113 //link template: select114 59 $this->add_control( 115 60 'ltemplate', 116 61 [ 117 'label' => esc_attr(__('Link Template', WPDM_ELEMENTOR)),62 'label' => __('Link Template', WPDM_ELEMENTOR), 118 63 'type' => \Elementor\Controls_Manager::SELECT2, 119 'options' => get_elementor_link_templates(),64 'options' => $this->getLinkTemplateOptions(), 120 65 'default' => 'link-template-panel' 121 66 ] … … 123 68 124 69 $this->end_controls_section(); 125 126 70 } 127 71 128 /** 129 * Render oEmbed widget output on the frontend. 130 * 131 * Written in PHP and used to generate the final HTML. 132 * 133 * @since 1.0.0 134 * @access protected 135 */ 136 protected function render() { 72 protected function render() 73 { 74 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 75 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 137 76 138 $settings = $this->get_settings_for_display(); 139 echo WPDM()->package->shortCodes->singlePackage(['id' => $settings['pid'], 'template' => $settings['ltemplate']]); 77 if (empty($settings['pid'])) { 78 return; 79 } 140 80 81 echo WPDM()->package->shortCodes->singlePackage([ 82 'id' => $settings['pid'], 83 'template' => $settings['ltemplate'] 84 ]); 141 85 } 142 143 86 } 144 87 -
wpdm-elementor/trunk/src/widgets/PackagesWidget.php
r3259585 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 6 7 class PackagesWidget extends Widget_Base 5 /** 6 * Packages Widget. 7 * Displays multiple packages with filtering options. 8 */ 9 class PackagesWidget extends BaseWidget 8 10 { 11 /** 12 * Expected settings keys for this widget. 13 */ 14 private const SETTINGS_KEYS = [ 15 'search', 'categories', 'include_children', 'tags', 'author', 16 'orderby', 'order', 'items_per_page', 'template', 17 'cols', 'colspad', 'colsphone', 'toolbar', 'paging', 'login', 'async' 18 ]; 19 20 /** 21 * Settings sanitization rules. 22 */ 23 private const SANITIZERS = [ 24 'search' => 'text', 25 'include_children' => 'text', 26 'author' => 'text', 27 'orderby' => 'orderby', 28 'order' => 'order', 29 'items_per_page' => 'int', 30 'template' => 'text', 31 'cols' => 'int', 32 'colspad' => 'int', 33 'colsphone' => 'int', 34 'toolbar' => 'text', 35 'paging' => 'text', 36 'login' => 'text', 37 'async' => 'text', 38 ]; 9 39 10 40 public function get_name() … … 15 45 public function get_title() 16 46 { 17 return 'Packages';47 return __('Packages', WPDM_ELEMENTOR); 18 48 } 19 49 … … 23 53 } 24 54 25 public function get_categories()26 {27 return ['wpdm'];28 }29 30 55 protected function register_controls() 31 56 { 32 33 57 $this->start_controls_section( 34 58 'content_section', 35 59 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)),60 'label' => __('Parameters', WPDM_ELEMENTOR), 37 61 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 62 ] 39 63 ); 40 64 41 //search keywords : TEXT filed42 65 $this->add_control( 43 66 'search', 44 67 [ 45 'label' => esc_attr(__('Search Keywords', WPDM_ELEMENTOR)),68 'label' => __('Search Keywords', WPDM_ELEMENTOR), 46 69 'type' => \Elementor\Controls_Manager::TEXT, 47 70 'input_type' => 'text', 48 'placeholder' => esc_attr(__('search keywords', WPDM_ELEMENTOR)), 49 ] 50 ); 51 52 //include categories: multi select 53 $wpdmcategory_terms = get_terms(['taxonomoy' => 'wpdmcategory']); 54 foreach($wpdmcategory_terms as $k => $t){ 55 $wpdmcategory_terms[$t->slug] = $t->name; 56 unset($wpdmcategory_terms[$k]); 57 }; 58 71 'placeholder' => __('search keywords', WPDM_ELEMENTOR), 72 ] 73 ); 59 74 60 75 $this->add_control( 61 76 'categories', 62 77 [ 63 'label' => esc_attr(__('Include Categories', WPDM_ELEMENTOR)),78 'label' => __('Include Categories', WPDM_ELEMENTOR), 64 79 'type' => \Elementor\Controls_Manager::SELECT2, 65 80 'multiple' => true, 66 'options' => $ wpdmcategory_terms,81 'options' => $this->getCategoryOptions(), 67 82 'default' => [] 68 83 ] 69 84 ); 70 85 71 //include children: radio72 86 $this->add_control( 73 87 'include_children', 74 88 [ 75 'label' => esc_attr(__('Include Children', WPDM_ELEMENTOR)),76 'type' => \Elementor\Controls_Manager::CHOOSE, 77 'options' => [ 78 '0' => ['title' => 'No', 'icon' => 'fa fa-times'],79 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check']89 'label' => __('Include Children', WPDM_ELEMENTOR), 90 'type' => \Elementor\Controls_Manager::CHOOSE, 91 'options' => [ 92 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 93 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 80 94 ], 81 95 'default' => '0' … … 83 97 ); 84 98 85 //category match: radios 86 87 //exclude categories: multi select 88 89 //tags: multi select 90 $post_tag_terms = get_terms(['taxonomy' => 'wpdmtag']); 91 if(is_array($post_tag_terms)) { 92 foreach ($post_tag_terms as $k => $t) { 93 $post_tag_terms[$t->slug] = $t->name; 94 unset($post_tag_terms[$k]); 95 }; 99 $tag_options = $this->getTagOptions(); 100 if (!empty($tag_options)) { 96 101 $this->add_control( 97 102 'tags', 98 103 [ 99 'label' => esc_attr(__('Tags', WPDM_ELEMENTOR)),104 'label' => __('Tags', WPDM_ELEMENTOR), 100 105 'type' => \Elementor\Controls_Manager::SELECT2, 101 106 'multiple' => true, 102 'options' => $ post_tag_terms,107 'options' => $tag_options, 103 108 'default' => [] 104 109 ] … … 106 111 } 107 112 108 //exclude packages with text: text109 110 //authors: Text111 113 $this->add_control( 112 114 'author', 113 115 [ 114 'label' => esc_attr(__('Authors', WPDM_ELEMENTOR)),116 'label' => __('Authors', WPDM_ELEMENTOR), 115 117 'type' => \Elementor\Controls_Manager::TEXT, 116 118 'input_type' => 'text', 117 'placeholder' => esc_attr(__('1, 2, 3', WPDM_ELEMENTOR)), 118 'description' => esc_attr(__('Author IDs seperated by comma', WPDM_ELEMENTOR)) 119 ] 120 ); 121 122 //exclude packages from author: text 123 124 125 126 //order by: Select 119 'placeholder' => __('1, 2, 3', WPDM_ELEMENTOR), 120 'description' => __('Author IDs separated by comma', WPDM_ELEMENTOR) 121 ] 122 ); 123 127 124 $this->add_control( 128 125 'orderby', 129 126 [ 130 'label' => esc_attr(__('Order By', WPDM_ELEMENTOR)),127 'label' => __('Order By', WPDM_ELEMENTOR), 131 128 'type' => \Elementor\Controls_Manager::SELECT2, 132 'options' => ['date' => 'Date', 'title' => 'Title'],129 'options' => ['date' => __('Date', WPDM_ELEMENTOR), 'title' => __('Title', WPDM_ELEMENTOR)], 133 130 'default' => 'date', 134 131 ] 135 132 ); 136 133 137 //order: Select138 134 $this->add_control( 139 135 'order', 140 136 [ 141 'label' => esc_attr(__('Order', WPDM_ELEMENTOR)),142 'type' => \Elementor\Controls_Manager::CHOOSE, 143 'options' => [ 144 'ASC' => ['title' => 'Ascending', 'icon' => 'fa fa-sort-alpha-down'],145 'DESC' => ['title' => 'Descending', 'icon' => 'fa fa-sort-alpha-up']137 'label' => __('Order', WPDM_ELEMENTOR), 138 'type' => \Elementor\Controls_Manager::CHOOSE, 139 'options' => [ 140 'ASC' => ['title' => __('Ascending', WPDM_ELEMENTOR), 'icon' => 'eicon-arrow-up'], 141 'DESC' => ['title' => __('Descending', WPDM_ELEMENTOR), 'icon' => 'eicon-arrow-down'] 146 142 ], 147 143 'default' => 'DESC', 148 'show_label' => false 149 ] 150 ); 151 152 //items per page: text number 144 'toggle' => false 145 ] 146 ); 147 153 148 $this->add_control( 154 149 'items_per_page', 155 150 [ 156 'label' => esc_attr(__('Items Per Page', WPDM_ELEMENTOR)),157 'type' => \Elementor\Controls_Manager:: TEXT,158 ' input_type' => 'number',159 ' default' => '10'160 ]161 );162 151 'label' => __('Items Per Page', WPDM_ELEMENTOR), 152 'type' => \Elementor\Controls_Manager::NUMBER, 153 'min' => 1, 154 'max' => 100, 155 'default' => 10 156 ] 157 ); 163 158 164 159 $this->add_control( 165 160 'template', 166 161 [ 167 'label' => esc_attr(__('Link Template', WPDM_ELEMENTOR)),162 'label' => __('Link Template', WPDM_ELEMENTOR), 168 163 'type' => \Elementor\Controls_Manager::SELECT2, 169 'options' => get_elementor_link_templates(),164 'options' => $this->getLinkTemplateOptions(), 170 165 'default' => 'link-template-default' 171 166 ] 172 167 ); 173 168 174 //cols web175 169 $this->add_control( 176 170 'cols', 177 171 [ 178 'label' => esc_attr(__('Columns In PC', WPDM_ELEMENTOR)),179 'type' => \Elementor\Controls_Manager:: TEXT,180 ' input_type' => 'number',181 ' default' => '3'182 ]183 );184 185 //cols tab 172 'label' => __('Columns (Desktop)', WPDM_ELEMENTOR), 173 'type' => \Elementor\Controls_Manager::NUMBER, 174 'min' => 1, 175 'max' => 6, 176 'default' => 3 177 ] 178 ); 179 186 180 $this->add_control( 187 181 'colspad', 188 182 [ 189 'label' => esc_attr(__('Columns In Tab', WPDM_ELEMENTOR)),190 'type' => \Elementor\Controls_Manager:: TEXT,191 ' input_type' => 'number',192 ' default' => '2'193 ]194 );195 196 //cols phone 183 'label' => __('Columns (Tablet)', WPDM_ELEMENTOR), 184 'type' => \Elementor\Controls_Manager::NUMBER, 185 'min' => 1, 186 'max' => 4, 187 'default' => 2 188 ] 189 ); 190 197 191 $this->add_control( 198 192 'colsphone', 199 193 [ 200 'label' => esc_attr(__('Columns In Phone', WPDM_ELEMENTOR)),201 'type' => \Elementor\Controls_Manager:: TEXT,202 ' input_type' => 'number',203 ' default' => '1'204 ]205 );206 207 //Show Toolbar: radio 194 'label' => __('Columns (Phone)', WPDM_ELEMENTOR), 195 'type' => \Elementor\Controls_Manager::NUMBER, 196 'min' => 1, 197 'max' => 2, 198 'default' => 1 199 ] 200 ); 201 208 202 $this->add_control( 209 203 'toolbar', 210 204 [ 211 'label' => esc_attr(__('Show Toolbar', WPDM_ELEMENTOR)),212 'type' => \Elementor\Controls_Manager::CHOOSE, 213 'options' => [ 214 '1' => ['title' => 'Show', 'icon' => 'fa fa-check'],215 '0' => ['title' => 'Hide', 'icon' => 'fa fa-times']205 'label' => __('Show Toolbar', WPDM_ELEMENTOR), 206 'type' => \Elementor\Controls_Manager::CHOOSE, 207 'options' => [ 208 '1' => ['title' => __('Show', WPDM_ELEMENTOR), 'icon' => 'eicon-check'], 209 '0' => ['title' => __('Hide', WPDM_ELEMENTOR), 'icon' => 'eicon-close'] 216 210 ], 217 211 'default' => '1', … … 219 213 ); 220 214 221 //show pagination: radio222 215 $this->add_control( 223 216 'paging', 224 217 [ 225 'label' => esc_attr(__('Paging', WPDM_ELEMENTOR)),226 'type' => \Elementor\Controls_Manager::CHOOSE, 227 'options' => [ 228 '1' => ['title' => 'Show', 'icon' => 'fa fa-check'],229 '0' => ['title' => 'Hide', 'icon' => 'fa fa-times']218 'label' => __('Pagination', WPDM_ELEMENTOR), 219 'type' => \Elementor\Controls_Manager::CHOOSE, 220 'options' => [ 221 '1' => ['title' => __('Show', WPDM_ELEMENTOR), 'icon' => 'eicon-check'], 222 '0' => ['title' => __('Hide', WPDM_ELEMENTOR), 'icon' => 'eicon-close'] 230 223 ], 231 224 'default' => '0', … … 233 226 ); 234 227 235 //Require login: choose236 228 $this->add_control( 237 229 'login', 238 230 [ 239 'label' => esc_attr(__('Require Login', WPDM_ELEMENTOR)),240 'type' => \Elementor\Controls_Manager::CHOOSE, 241 'options' => [ 242 '0' => ['title' => 'No', 'icon' => 'fa fa-times'],243 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check']231 'label' => __('Require Login', WPDM_ELEMENTOR), 232 'type' => \Elementor\Controls_Manager::CHOOSE, 233 'options' => [ 234 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 235 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 244 236 ], 245 237 'default' => '0' … … 247 239 ); 248 240 249 //enable async request: radio250 241 $this->add_control( 251 242 'async', 252 243 [ 253 'label' => esc_attr(__('Async', WPDM_ELEMENTOR)),254 'type' => \Elementor\Controls_Manager::CHOOSE, 255 'options' => [ 256 '1' => ['title' => 'Enable', 'icon' => 'fa fa-check'],257 '0' => ['title' => 'Disable', 'icon' => 'fa fa-times']244 'label' => __('Async Loading', WPDM_ELEMENTOR), 245 'type' => \Elementor\Controls_Manager::CHOOSE, 246 'options' => [ 247 '1' => ['title' => __('Enable', WPDM_ELEMENTOR), 'icon' => 'eicon-check'], 248 '0' => ['title' => __('Disable', WPDM_ELEMENTOR), 'icon' => 'eicon-close'] 258 249 ], 259 250 'default' => '1', … … 264 255 } 265 256 266 267 268 257 protected function render() 269 258 { 270 271 $settings = $this->get_settings_for_display(); 272 $cus_settings = array_slice($settings, 0, 20); 273 274 if(isset($cus_settings['categories']) && is_array($cus_settings['categories'])) 275 $cus_settings['categories'] = implode(",", $cus_settings['categories']); 276 if(isset($cus_settings['tags']) && is_array($cus_settings['tags'])) 277 $cus_settings['tags'] = implode(",", $cus_settings['tags']); 278 279 //echo '<div class="oembed-elementor-widget">'; 280 281 echo WPDM()->package->shortCodes->packages($cus_settings); 282 283 //echo '</div>'; 259 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 260 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 261 262 // Convert arrays to comma-separated strings 263 $settings = $this->arraysToComma($settings, ['categories', 'tags']); 264 265 echo WPDM()->package->shortCodes->packages($settings); 284 266 } 285 267 } -
wpdm-elementor/trunk/src/widgets/RegFormWidget.php
r2844275 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 5 /** 6 * Registration Form Widget. 7 * Displays a user registration form. 8 */ 9 class RegFormWidget extends BaseWidget 10 { 11 /** 12 * Expected settings keys for this widget. 13 */ 14 private const SETTINGS_KEYS = ['captcha', 'verifyemail', 'autologin', 'logo']; 6 15 7 class RegFormWidget extends Widget_Base 8 { 16 /** 17 * Settings sanitization rules. 18 */ 19 private const SANITIZERS = [ 20 'captcha' => 'bool', 21 'verifyemail' => 'bool', 22 'autologin' => 'bool', 23 'logo' => 'url', 24 ]; 9 25 10 26 public function get_name() … … 15 31 public function get_title() 16 32 { 17 return 'Registration Form';33 return __('Registration Form', WPDM_ELEMENTOR); 18 34 } 19 35 … … 23 39 } 24 40 25 public function get_categories()26 {27 return ['wpdm'];28 }29 30 41 protected function register_controls() 31 42 { 32 33 43 $this->start_controls_section( 34 44 'content_section', 35 45 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)),46 'label' => __('Parameters', WPDM_ELEMENTOR), 37 47 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 48 ] 39 49 ); 40 50 41 42 // captcha: optional, default value "true", shows/hides captcha with registration form on true/false43 51 $this->add_control( 44 52 'captcha', 45 53 [ 46 'label' => esc_attr(__('Captcha', WPDM_ELEMENTOR)),54 'label' => __('Show Captcha', WPDM_ELEMENTOR), 47 55 'type' => \Elementor\Controls_Manager::CHOOSE, 48 56 'options' => [ 49 '0' => ['title' => 'No', 'icon' => 'fa fa-times'], 50 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check'] 51 ], 52 'default' => '1' 53 ] 54 ); 55 //verifyemail: optional, the default value is true, if the value is false, it shows the password field with registration form and doesn't send verification email, otherwise, it doesn't show the password field and send the password to registered email. 56 $this->add_control( 57 'verifyemail', 58 [ 59 'label' => esc_attr(__('Verify Email', WPDM_ELEMENTOR)), 60 'type' => \Elementor\Controls_Manager::CHOOSE, 61 'options' => [ 62 '0' => ['title' => 'No', 'icon' => 'fa fa-times'], 63 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check'] 57 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 58 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 64 59 ], 65 60 'default' => '1' … … 67 62 ); 68 63 69 //autologin: optional, default value is "false" when "verifyemail" is true, the default value is "true" when "verifyemail" is 0, after registration, it will auto-login when the value is true otherwise redirect to the login page. 64 $this->add_control( 65 'verifyemail', 66 [ 67 'label' => __('Verify Email', WPDM_ELEMENTOR), 68 'type' => \Elementor\Controls_Manager::CHOOSE, 69 'options' => [ 70 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 71 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 72 ], 73 'default' => '1', 74 'description' => __('Send password via email when enabled', WPDM_ELEMENTOR) 75 ] 76 ); 77 70 78 $this->add_control( 71 79 'autologin', 72 80 [ 73 'label' => esc_attr(__('Auto Login', WPDM_ELEMENTOR)),81 'label' => __('Auto Login', WPDM_ELEMENTOR), 74 82 'type' => \Elementor\Controls_Manager::CHOOSE, 75 83 'options' => [ 76 '0' => ['title' => 'No', 'icon' => 'fa fa-times'],77 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check']84 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 85 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 78 86 ], 79 'default' => '0' 87 'default' => '0', 88 'description' => __('Automatically log in user after registration', WPDM_ELEMENTOR) 80 89 ] 81 90 ); 82 91 83 84 //logo: optional, add a logo or any image URL you want to show at the top of the registration form85 92 $this->add_control( 86 93 'logo', 87 94 [ 88 'label' => esc_attr(__('Logo URL', WPDM_ELEMENTOR)),95 'label' => __('Logo URL', WPDM_ELEMENTOR), 89 96 'type' => \Elementor\Controls_Manager::TEXT, 90 97 'input_type' => 'url', 91 'placeholder' => esc_attr(__('Logo Url', WPDM_ELEMENTOR)),92 'description' => 'optional, add the logo or any image URL you want to show on top of the login form'98 'placeholder' => __('Logo URL', WPDM_ELEMENTOR), 99 'description' => __('Image URL to show on top of the form', WPDM_ELEMENTOR) 93 100 ] 94 101 ); 95 96 97 102 98 103 $this->end_controls_section(); 99 104 } 100 105 101 102 103 106 protected function render() 104 107 { 108 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 109 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 105 110 106 $settings = $this->get_settings_for_display(); 107 $cus_settings = array_slice($settings, 0, 5); 108 $cus_settings['captcha'] = (bool) $cus_settings['captcha']; 109 $cus_settings['verifyemail'] = (bool) $cus_settings['verifyemail']; 110 $cus_settings['autologin'] = (bool) $cus_settings['autologin']; 111 112 echo WPDM()->user->register->form($cus_settings); 113 111 echo $this->wrapOutput( 112 WPDM()->user->register->form($settings), 113 'registration-form-widget' 114 ); 114 115 } 115 116 } -
wpdm-elementor/trunk/src/widgets/SearchResultWidget.php
r2844275 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 5 /** 6 * Search Result Widget. 7 * Displays search box and search results. 8 */ 9 class SearchResultWidget extends BaseWidget 10 { 11 /** 12 * Expected settings keys for this widget. 13 */ 14 private const SETTINGS_KEYS = ['template', 'init', 'cols']; 6 15 7 class SearchResultWidget extends Widget_Base 8 { 16 /** 17 * Settings sanitization rules. 18 */ 19 private const SANITIZERS = [ 20 'template' => 'text', 21 'init' => 'text', 22 'cols' => 'int', 23 ]; 9 24 10 25 public function get_name() … … 15 30 public function get_title() 16 31 { 17 return 'Search Result';32 return __('Search Result', WPDM_ELEMENTOR); 18 33 } 19 34 … … 23 38 } 24 39 25 public function get_categories()26 {27 return ['wpdm'];28 }29 30 40 protected function register_controls() 31 41 { 32 33 42 $this->start_controls_section( 34 43 'content_section', 35 44 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)),45 'label' => __('Parameters', WPDM_ELEMENTOR), 37 46 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 47 ] 39 48 ); 40 49 41 //link template: select42 50 $this->add_control( 43 51 'template', 44 52 [ 45 'label' => esc_attr(__('Link Template', WPDM_ELEMENTOR)),53 'label' => __('Link Template', WPDM_ELEMENTOR), 46 54 'type' => \Elementor\Controls_Manager::SELECT2, 47 55 'options' => get_wpdm_link_templates(), 48 'default' => 'link- default-default'56 'default' => 'link-template-default' 49 57 ] 50 58 ); 51 59 52 //init: 1 if you want to show some results initially, like the latest packages, skip the parameter or 0 if you don't want to show any package until you search53 60 $this->add_control( 54 61 'init', 55 62 [ 56 'label' => esc_attr(__('Require Login', WPDM_ELEMENTOR)),63 'label' => __('Show Initial Results', WPDM_ELEMENTOR), 57 64 'type' => \Elementor\Controls_Manager::CHOOSE, 58 65 'options' => [ 59 '0' => ['title' => 'No', 'icon' => 'fa fa-times'],60 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check']66 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 67 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 61 68 ], 62 'default' => '1' 69 'default' => '1', 70 'description' => __('Show latest packages before search', WPDM_ELEMENTOR) 63 71 ] 64 72 ); 65 66 //cols: 1 or 2 or 3 or 4 columns search result 73 67 74 $this->add_control( 68 75 'cols', 69 76 [ 70 'label' => esc_attr(__('Columns', WPDM_ELEMENTOR)), 71 'type' => \Elementor\Controls_Manager::TEXT, 72 'input_type' => 'number', 73 'default' => '3' 77 'label' => __('Columns', WPDM_ELEMENTOR), 78 'type' => \Elementor\Controls_Manager::NUMBER, 79 'min' => 1, 80 'max' => 4, 81 'default' => 3 74 82 ] 75 83 ); … … 78 86 } 79 87 80 81 82 88 protected function render() 83 89 { 90 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 91 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 84 92 85 $settings = $this->get_settings_for_display(); 86 $cus_settings = array_slice($settings, 0, 4); 87 88 89 echo WPDM()->package->shortCodes->searchResult($cus_settings); 90 93 echo WPDM()->package->shortCodes->searchResult($settings); 91 94 } 92 95 } -
wpdm-elementor/trunk/src/widgets/TagWidget.php
r3259585 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 6 7 class TagWidget extends Widget_Base 5 /** 6 * Tag Widget. 7 * Displays packages filtered by tags. 8 * Note: This widget is currently disabled in Main.php 9 */ 10 class TagWidget extends BaseWidget 8 11 { 12 /** 13 * Expected settings keys for this widget. 14 */ 15 private const SETTINGS_KEYS = [ 16 'tagid', 'title', 'desc', 'items_per_page', 17 'orderby', 'order', 'template', 18 'cols', 'colspad', 'colsphone', 'toolbar' 19 ]; 20 21 /** 22 * Settings sanitization rules. 23 */ 24 private const SANITIZERS = [ 25 'title' => 'text', 26 'desc' => 'text', 27 'items_per_page' => 'int', 28 'orderby' => 'orderby', 29 'order' => 'order', 30 'template' => 'text', 31 'cols' => 'int', 32 'colspad' => 'int', 33 'colsphone' => 'int', 34 'toolbar' => 'text', 35 ]; 9 36 10 37 public function get_name() … … 15 42 public function get_title() 16 43 { 17 return 'Packages By Tags';44 return __('Packages By Tags', WPDM_ELEMENTOR); 18 45 } 19 46 20 47 public function get_icon() 21 48 { 22 return 'fa fa-tags'; 23 } 24 25 public function get_categories() 26 { 27 return ['wpdm']; 49 return 'eicon-tags'; 28 50 } 29 51 30 52 protected function register_controls() 31 53 { 32 33 54 $this->start_controls_section( 34 55 'content_section', 35 56 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)),57 'label' => __('Parameters', WPDM_ELEMENTOR), 37 58 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 59 ] 39 60 ); 40 61 41 42 //categories: multi select43 62 $this->add_control( 44 63 'tagid', 45 64 [ 46 'label' => esc_attr(__('Tags', WPDM_ELEMENTOR)),65 'label' => __('Tags', WPDM_ELEMENTOR), 47 66 'type' => \Elementor\Controls_Manager::SELECT2, 48 67 'multiple' => true, 49 'options' => get_wpdmcategory_terms(),68 'options' => $this->getTagOptions(), 50 69 'default' => [] 51 70 ] 52 71 ); 53 72 54 //title: Text55 73 $this->add_control( 56 74 'title', 57 75 [ 58 'label' => esc_attr(__('Title', WPDM_ELEMENTOR)),76 'label' => __('Title', WPDM_ELEMENTOR), 59 77 'type' => \Elementor\Controls_Manager::TEXT, 60 78 'input_type' => 'text', 61 'description' => esc_attr(__('You can use any text there, if you use “1” then it will show the Tag title', WPDM_ELEMENTOR)),79 'description' => __('Use "1" to show tag title, or enter custom text', WPDM_ELEMENTOR), 62 80 'default' => '1' 63 81 ] 64 82 ); 65 83 66 //description: Text67 84 $this->add_control( 68 85 'desc', 69 86 [ 70 'label' => esc_attr(__('Description', WPDM_ELEMENTOR)),87 'label' => __('Description', WPDM_ELEMENTOR), 71 88 'type' => \Elementor\Controls_Manager::TEXT, 72 89 'input_type' => 'text', 73 'description' => esc_attr(__('You can use any text there, if you use “1” then it will show the tag description', WPDM_ELEMENTOR)),90 'description' => __('Use "1" to show tag description, or enter custom text', WPDM_ELEMENTOR), 74 91 'default' => '1' 75 76 ] 77 ); 78 79 //items per page: text number 92 ] 93 ); 94 80 95 $this->add_control( 81 96 'items_per_page', 82 97 [ 83 'label' => esc_attr(__('Items Per Page', WPDM_ELEMENTOR)), 84 'type' => \Elementor\Controls_Manager::TEXT, 85 'input_type' => 'number', 86 'default' => '10' 87 ] 88 ); 89 90 91 //order by: Select 98 'label' => __('Items Per Page', WPDM_ELEMENTOR), 99 'type' => \Elementor\Controls_Manager::NUMBER, 100 'min' => 1, 101 'max' => 100, 102 'default' => 10 103 ] 104 ); 105 92 106 $this->add_control( 93 107 'orderby', 94 108 [ 95 'label' => esc_attr(__('Order By', WPDM_ELEMENTOR)),109 'label' => __('Order By', WPDM_ELEMENTOR), 96 110 'type' => \Elementor\Controls_Manager::SELECT2, 97 'options' => ['date' => 'Date', 'title' => 'Title'],111 'options' => ['date' => __('Date', WPDM_ELEMENTOR), 'title' => __('Title', WPDM_ELEMENTOR)], 98 112 'default' => 'date', 99 113 ] 100 114 ); 101 115 102 //order: Choose103 116 $this->add_control( 104 117 'order', 105 118 [ 106 'label' => esc_attr(__('Order', WPDM_ELEMENTOR)),119 'label' => __('Order', WPDM_ELEMENTOR), 107 120 'type' => \Elementor\Controls_Manager::CHOOSE, 108 121 'options' => [ 109 'ASC' => ['title' => 'Ascending', 'icon' => 'fa fa-sort-alpha-down'],110 'DESC' => ['title' => 'Descending', 'icon' => 'fa fa-sort-alpha-up']122 'ASC' => ['title' => __('Ascending', WPDM_ELEMENTOR), 'icon' => 'eicon-arrow-up'], 123 'DESC' => ['title' => __('Descending', WPDM_ELEMENTOR), 'icon' => 'eicon-arrow-down'] 111 124 ], 112 125 'default' => 'DESC', 113 'show_label' => false 114 ] 115 ); 116 117 118 //link template: select 126 'toggle' => false 127 ] 128 ); 119 129 120 130 $this->add_control( 121 131 'template', 122 132 [ 123 'label' => esc_attr(__('Link Template', WPDM_ELEMENTOR)),133 'label' => __('Link Template', WPDM_ELEMENTOR), 124 134 'type' => \Elementor\Controls_Manager::SELECT2, 125 135 'options' => get_wpdm_link_templates(), 126 'default' => 'link-default-default' 127 ] 128 ); 129 130 131 //cols web 136 'default' => 'link-template-default' 137 ] 138 ); 139 132 140 $this->add_control( 133 141 'cols', 134 142 [ 135 'label' => esc_attr(__('Columns In PC', WPDM_ELEMENTOR)),136 'type' => \Elementor\Controls_Manager:: TEXT,137 ' input_type' => 'number',138 ' default' => '3'139 ]140 );141 142 //cols tab 143 'label' => __('Columns (Desktop)', WPDM_ELEMENTOR), 144 'type' => \Elementor\Controls_Manager::NUMBER, 145 'min' => 1, 146 'max' => 6, 147 'default' => 3 148 ] 149 ); 150 143 151 $this->add_control( 144 152 'colspad', 145 153 [ 146 'label' => esc_attr(__('Columns In Tab', WPDM_ELEMENTOR)),147 'type' => \Elementor\Controls_Manager:: TEXT,148 ' input_type' => 'number',149 ' default' => '2'150 ]151 );152 153 //cols phone 154 'label' => __('Columns (Tablet)', WPDM_ELEMENTOR), 155 'type' => \Elementor\Controls_Manager::NUMBER, 156 'min' => 1, 157 'max' => 4, 158 'default' => 2 159 ] 160 ); 161 154 162 $this->add_control( 155 163 'colsphone', 156 164 [ 157 'label' => esc_attr(__('Columns In Phone', WPDM_ELEMENTOR)),158 'type' => \Elementor\Controls_Manager:: TEXT,159 ' input_type' => 'number',160 ' default' => '1'161 ]162 );163 164 //Show Toolbar: radio 165 'label' => __('Columns (Phone)', WPDM_ELEMENTOR), 166 'type' => \Elementor\Controls_Manager::NUMBER, 167 'min' => 1, 168 'max' => 2, 169 'default' => 1 170 ] 171 ); 172 165 173 $this->add_control( 166 174 'toolbar', 167 175 [ 168 'label' => esc_attr(__('Show Toolbar', WPDM_ELEMENTOR)),176 'label' => __('Show Toolbar', WPDM_ELEMENTOR), 169 177 'type' => \Elementor\Controls_Manager::CHOOSE, 170 178 'options' => [ 171 '1' => ['title' => 'Show', 'icon' => 'fa fa-check'],172 '0' => ['title' => 'Hide', 'icon' => 'fa fa-times']179 '1' => ['title' => __('Show', WPDM_ELEMENTOR), 'icon' => 'eicon-check'], 180 '0' => ['title' => __('Hide', WPDM_ELEMENTOR), 'icon' => 'eicon-close'] 173 181 ], 174 182 'default' => '1', … … 179 187 } 180 188 181 182 183 189 protected function render() 184 190 { 185 186 $settings = $this->get_settings_for_display(); 187 $cus_settings = array_slice($settings, 0, 15); 188 189 $cus_settings['id'] = implode(",", $cus_settings['tagid']); 190 191 echo WPDM()->package->shortCodes->packagesByTag($cus_settings); 192 191 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 192 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 193 194 if (empty($settings['tagid'])) { 195 return; 196 } 197 198 // Convert tagid array to comma-separated id 199 $settings['id'] = is_array($settings['tagid']) 200 ? implode(',', array_map('sanitize_text_field', $settings['tagid'])) 201 : sanitize_text_field($settings['tagid']); 202 203 unset($settings['tagid']); 204 205 echo WPDM()->package->shortCodes->packagesByTag($settings); 193 206 } 194 207 } -
wpdm-elementor/trunk/src/widgets/UserDashboardWidget.php
r2844275 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 5 /** 6 * User Dashboard Widget. 7 * Displays user dashboard with favorites and recommendations. 8 */ 9 class UserDashboardWidget extends BaseWidget 10 { 11 /** 12 * Expected settings keys for this widget. 13 */ 14 private const SETTINGS_KEYS = ['logo', 'recommended', 'fav', 'signup', 'flaturl']; 6 15 7 class UserDashboardWidget extends Widget_Base 8 { 16 /** 17 * Settings sanitization rules. 18 */ 19 private const SANITIZERS = [ 20 'logo' => 'url', 21 'recommended' => 'text', 22 'fav' => 'text', 23 'signup' => 'text', 24 'flaturl' => 'text', 25 ]; 9 26 10 27 public function get_name() … … 15 32 public function get_title() 16 33 { 17 return 'User Dashboard';34 return __('User Dashboard', WPDM_ELEMENTOR); 18 35 } 19 36 … … 23 40 } 24 41 25 public function get_categories()26 {27 return ['wpdm'];28 }29 30 42 protected function register_controls() 31 43 { 32 33 44 $this->start_controls_section( 34 45 'content_section', 35 46 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)),47 'label' => __('Parameters', WPDM_ELEMENTOR), 37 48 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 49 ] 39 50 ); 40 51 41 42 //logo optional, add the logo or any image URL you want to show on top of the login form43 52 $this->add_control( 44 53 'logo', 45 54 [ 46 'label' => esc_attr(__('Logo URL', WPDM_ELEMENTOR)),55 'label' => __('Logo URL', WPDM_ELEMENTOR), 47 56 'type' => \Elementor\Controls_Manager::TEXT, 48 57 'input_type' => 'url', 49 'placeholder' => esc_attr(__('Logo Url', WPDM_ELEMENTOR)),50 'description' => 'optional, add the logo or any image URL you want to show on top of the login form'58 'placeholder' => __('Logo URL', WPDM_ELEMENTOR), 59 'description' => __('Image URL to show on top of the dashboard', WPDM_ELEMENTOR) 51 60 ] 52 61 ); 53 62 54 //recommended value should be a category slug if you want to recommend specific category items, if you want to show recent items, use recommend="recent", skip the parameter recommended if you want to hide recommended items on the dashboard.55 63 $this->add_control( 56 64 'recommended', 57 65 [ 58 'label' => esc_attr(__('Recommended', WPDM_ELEMENTOR)),66 'label' => __('Recommended', WPDM_ELEMENTOR), 59 67 'type' => \Elementor\Controls_Manager::TEXT, 60 68 'input_type' => 'text', 61 69 'default' => 'recent', 62 'placeholder' => esc_attr(__('Recommended', WPDM_ELEMENTOR)),63 'description' => 'value should be a category slug if you want to recommend specific category items, if you want to show recent items, use recommend="recent", skip the parameter recommended if you want to hide recommended items on the dashboard'70 'placeholder' => __('Category slug or "recent"', WPDM_ELEMENTOR), 71 'description' => __('Use category slug or "recent" for latest items', WPDM_ELEMENTOR) 64 72 ] 65 73 ); 66 74 67 //fav fav=1 if you want to show users favorite section and skip the fav parameter if you want to hide the section68 75 $this->add_control( 69 76 'fav', 70 77 [ 71 'label' => esc_attr(__('Show Favorite Section', WPDM_ELEMENTOR)),78 'label' => __('Show Favorites Section', WPDM_ELEMENTOR), 72 79 'type' => \Elementor\Controls_Manager::CHOOSE, 73 80 'options' => [ 74 '0' => ['title' => 'No', 'icon' => 'fa fa-times'],75 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check']81 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 82 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 76 83 ], 77 84 'default' => '1' … … 79 86 ); 80 87 81 //signup use signup=1 if you want to show login + signup form when a user is not logged in, signup=0 or skip the parameter if you only want to show the login form.82 88 $this->add_control( 83 89 'signup', 84 90 [ 85 'label' => esc_attr(__('show login + signup', WPDM_ELEMENTOR)),91 'label' => __('Show Login + Signup', WPDM_ELEMENTOR), 86 92 'type' => \Elementor\Controls_Manager::CHOOSE, 87 93 'options' => [ 88 '0' => ['title' => 'No', 'icon' => 'fa fa-times'],89 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check']94 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 95 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 90 96 ], 91 'default' => '1' 97 'default' => '1', 98 'description' => __('Show signup form when user is not logged in', WPDM_ELEMENTOR) 92 99 ] 93 100 ); 94 101 95 //flaturl Optional parameter, default value 0, use flaturl=1 for flat url96 102 $this->add_control( 97 103 'flaturl', 98 104 [ 99 'label' => esc_attr(__('Flat Url', WPDM_ELEMENTOR)),105 'label' => __('Flat URL', WPDM_ELEMENTOR), 100 106 'type' => \Elementor\Controls_Manager::CHOOSE, 101 107 'options' => [ 102 '0' => ['title' => 'No', 'icon' => 'fa fa-times'],103 '1' => ['title' => 'Yes', 'icon' => 'fa fa-check']108 '0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], 109 '1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] 104 110 ], 105 111 'default' => '0' … … 107 113 ); 108 114 109 110 115 $this->end_controls_section(); 111 116 } 112 117 113 114 115 118 protected function render() 116 119 { 120 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 121 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 117 122 118 $settings = $this->get_settings_for_display(); 119 $cus_settings = array_slice($settings, 0, 3); 120 121 echo '<div class="oembed-elementor-widget">'; 122 // p($cus_settings); 123 echo WPDM()->user->dashboard->dashboard($cus_settings); 124 125 echo '</div>'; 123 echo $this->wrapOutput( 124 WPDM()->user->dashboard->dashboard($settings), 125 'user-dashboard-widget' 126 ); 126 127 } 127 128 } -
wpdm-elementor/trunk/src/widgets/UserProfileWidget.php
r2844275 r3427512 3 3 namespace WPDM\Elementor\Widgets; 4 4 5 use Elementor\Widget_Base; 5 /** 6 * User Profile Widget. 7 * Displays user profile. 8 * Note: This widget is currently disabled in Main.php 9 */ 10 class UserProfileWidget extends BaseWidget 11 { 12 /** 13 * Expected settings keys for this widget. 14 */ 15 private const SETTINGS_KEYS = ['template']; 6 16 7 class UserProfileWidget extends Widget_Base 8 { 17 /** 18 * Settings sanitization rules. 19 */ 20 private const SANITIZERS = [ 21 'template' => 'text', 22 ]; 9 23 10 24 public function get_name() … … 15 29 public function get_title() 16 30 { 17 return 'User Profile';31 return __('User Profile', WPDM_ELEMENTOR); 18 32 } 19 33 20 34 public function get_icon() 21 35 { 22 return 'fa fa-user-o'; 23 } 24 25 public function get_categories() 26 { 27 return ['wpdm']; 36 return 'eicon-user-circle-o'; 28 37 } 29 38 30 39 protected function register_controls() 31 40 { 32 33 41 $this->start_controls_section( 34 42 'content_section', 35 43 [ 36 'label' => esc_attr(__('Parameters', WPDM_ELEMENTOR)),44 'label' => __('Parameters', WPDM_ELEMENTOR), 37 45 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, 38 46 ] 39 47 ); 40 48 41 //link template: select42 49 $this->add_control( 43 50 'template', 44 51 [ 45 'label' => esc_attr(__('Link Template', WPDM_ELEMENTOR)),52 'label' => __('Link Template', WPDM_ELEMENTOR), 46 53 'type' => \Elementor\Controls_Manager::SELECT2, 47 54 'options' => get_wpdm_link_templates(), 48 'default' => 'link- default-default'55 'default' => 'link-template-default' 49 56 ] 50 57 ); 51 52 58 53 59 $this->end_controls_section(); 54 60 } 55 61 56 57 58 62 protected function render() 59 63 { 64 $settings = $this->getCleanSettings(self::SETTINGS_KEYS); 65 $settings = $this->sanitizeSettings($settings, self::SANITIZERS); 60 66 61 $settings = $this->get_settings_for_display(); 62 $cus_settings = array_slice($settings, 0, 5); 63 64 echo '<div class="oembed-elementor-widget">'; 65 // p($cus_settings); 66 echo WPDM()->user->profile->profile($cus_settings); 67 68 echo '</div>'; 67 echo $this->wrapOutput( 68 WPDM()->user->profile->profile($settings), 69 'user-profile-widget' 70 ); 69 71 } 70 72 } -
wpdm-elementor/trunk/wpdm-elementor.php
r3259585 r3427512 4 4 * Plugin URI: https://www.wpdownloadmanager.com/download/wpdm-elementor/ 5 5 * Description: Download Manger modules for Elementor 6 * Version: 1.3.06 * Version: 2.0.0 7 7 * Author: WordPress Download Manager 8 8 * Text Domain: wpdm-elementor … … 12 12 */ 13 13 14 use WPDM\Elementor\Main; 14 if (!defined('ABSPATH')) { 15 exit; 16 } 15 17 16 define("__WPDM_ELEMENTOR__", true); 18 /** 19 * Check for required dependencies 20 */ 21 function wpdm_elementor_check_dependencies() { 22 $missing = []; 17 23 18 require_once __DIR__.'/src/api/API.php'; 19 require_once __DIR__.'/src/Main.php'; 24 if (!did_action('elementor/loaded')) { 25 $missing[] = 'Elementor'; 26 } 20 27 21 Main::getInstance(); 28 if (!function_exists('WPDM')) { 29 $missing[] = 'WordPress Download Manager'; 30 } 31 32 return $missing; 33 } 34 35 /** 36 * Display admin notice for missing dependencies 37 */ 38 function wpdm_elementor_missing_dependencies_notice() { 39 $missing = wpdm_elementor_check_dependencies(); 40 if (empty($missing)) { 41 return; 42 } 43 44 $message = sprintf( 45 '<strong>WPDM - Elementor</strong> requires %s to be installed and activated.', 46 implode(' and ', $missing) 47 ); 48 49 printf('<div class="notice notice-error"><p>%s</p></div>', $message); 50 } 51 add_action('admin_notices', 'wpdm_elementor_missing_dependencies_notice'); 52 53 /** 54 * Initialize plugin only if dependencies are met 55 */ 56 function wpdm_elementor_init() { 57 $missing = wpdm_elementor_check_dependencies(); 58 if (!empty($missing)) { 59 return; 60 } 61 62 define("__WPDM_ELEMENTOR__", true); 63 64 // Load constants first 65 require_once __DIR__.'/src/constants.php'; 66 67 require_once __DIR__.'/src/api/API.php'; 68 require_once __DIR__.'/src/Main.php'; 69 70 \WPDM\Elementor\Main::getInstance(); 71 } 72 add_action('plugins_loaded', 'wpdm_elementor_init');
Note: See TracChangeset
for help on using the changeset viewer.