PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.2.3
JetFormBuilder — Dynamic Blocks Form Builder v3.2.3
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 All 130 releases
← All changes | includes/classes/tools.php +1 -216 3.6.43.2.3 View file →
@@ -2,9 +2,8 @@
2 2
3 3 namespace Jet_Form_Builder\Classes;
4 4
5 5 use Jet_Form_Builder\Plugin;
6 -use Jet_Form_Builder\Generators\Registry as GeneratorRegistry;
7 6
8 7 // If this file is called directly, abort.
9 8 if ( ! defined( 'WPINC' ) ) {
10 9 die;
@@ -144,26 +143,8 @@
144 143
145 144 return self::prepare_list_for_js( $generators );
146 145 }
147 146
148 - /**
149 - * Get generator schemas for JS localization.
150 - *
151 - * @return array
152 - */
153 - public static function get_generator_schemas_for_js(): array {
154 - if ( ! class_exists( GeneratorRegistry::class ) ) {
155 - return array();
156 - }
157 -
158 - try {
159 - $registry = GeneratorRegistry::instance();
160 - return $registry->get_schemas_for_js();
161 - } catch ( \Exception $e ) {
162 - return array();
163 - }
164 - }
165 -
166 147 public static function get_allowed_mimes_list_for_js(): array {
167 148 return array_values( get_allowed_mime_types() );
168 149 }
169 150
@@ -226,26 +207,9 @@
226 207 $args
227 208 )
228 209 );
229 210
230 - $prepared_list_for_js = self::prepare_list_for_js( $posts, 'ID', 'post_title', $for_elementor );
231 -
232 - if ( true === $for_elementor ) {
233 - $manual_form_option = array(
234 - 'manual_form_id' => __( 'Enter Form ID Manually / Dynamically', 'jet-form-builder' ),
235 - );
236 -
237 - $prepared_list_for_js = array_replace( $manual_form_option, $prepared_list_for_js );
238 - } else {
239 - $manual_form_option[] = array(
240 - 'value' => -1,
241 - 'label' => __( 'Enter Form ID Manually / Dynamically', 'jet-form-builder' ),
242 - );
243 -
244 - $prepared_list_for_js = array_merge( $manual_form_option, $prepared_list_for_js );
245 - }
246 -
247 - return $prepared_list_for_js;
211 + return self::prepare_list_for_js( $posts, 'ID', 'post_title', $for_elementor );
248 212 }
249 213
250 214 /**
251 215 * Returns all registered user roles
@@ -272,110 +236,8 @@
272 236 }
273 237 }
274 238
275 239 /**
276 - * Returns editable roles and ensures the core helper is loaded.
277 - *
278 - * @return array
279 - */
280 - public static function get_editable_roles_safe(): array {
281 - if ( ! function_exists( 'get_editable_roles' ) ) {
282 - require_once ABSPATH . 'wp-admin/includes/user.php';
283 - }
284 -
285 - if ( ! function_exists( 'get_editable_roles' ) ) {
286 - return array();
287 - }
288 -
289 - return get_editable_roles();
290 - }
291 -
292 - /**
293 - * Returns all registered roles without filtering by the current user's capabilities.
294 - *
295 - * @return array
296 - */
297 - public static function get_registered_roles_safe(): array {
298 - $wp_roles = wp_roles();
299 -
300 - if ( ! is_a( $wp_roles, \WP_Roles::class ) ) {
301 - return array();
302 - }
303 -
304 - return $wp_roles->roles ?? array();
305 - }
306 -
307 - /**
308 - * Returns auto-detected low-privilege roles that can be used as
309 - * a starting point for self-service role transitions.
310 - *
311 - * @return string[]
312 - */
313 - public static function get_default_self_promotable_roles(): array {
314 - $editable_roles = self::get_registered_roles_safe();
315 -
316 - if ( empty( $editable_roles ) ) {
317 - return array();
318 - }
319 -
320 - $roles = array();
321 -
322 - foreach ( array_keys( $editable_roles ) as $role ) {
323 - if ( self::is_safe_self_promotable_role( $role ) ) {
324 - $roles[] = $role;
325 - }
326 - }
327 -
328 - return array_values( array_unique( $roles ) );
329 - }
330 -
331 - public static function is_safe_self_promotable_role( string $role ): bool {
332 - if ( 'administrator' === $role ) {
333 - return false;
334 - }
335 -
336 - $wp_roles = wp_roles();
337 -
338 - if ( ! isset( $wp_roles->roles[ $role ] ) ) {
339 - return false;
340 - }
341 -
342 - $caps = array_filter( $wp_roles->roles[ $role ]['capabilities'] ?? array() );
343 -
344 - $dangerous_caps = array(
345 - 'activate_plugins',
346 - 'create_users',
347 - 'delete_users',
348 - 'edit_users',
349 - 'list_users',
350 - 'promote_users',
351 - 'remove_users',
352 - 'manage_options',
353 - 'edit_theme_options',
354 - 'switch_themes',
355 - 'install_plugins',
356 - 'update_plugins',
357 - 'delete_plugins',
358 - 'install_themes',
359 - 'update_themes',
360 - 'delete_themes',
361 - 'unfiltered_html',
362 - 'edit_others_posts',
363 - 'delete_others_posts',
364 - 'publish_posts',
365 - 'manage_categories',
366 - );
367 -
368 - foreach ( $dangerous_caps as $cap ) {
369 - if ( ! empty( $caps[ $cap ] ) ) {
370 - return false;
371 - }
372 - }
373 -
374 - return true;
375 - }
376 -
377 - /**
378 240 * Prepare passed array for using in JS options
379 241 *
380 242 * @param array $array
381 243 * @param null $value_key
@@ -767,83 +629,6 @@
767 629
768 630 public static function is_empty( $value ): bool {
769 631 return '0' !== $value && 0 !== $value && empty( $value );
770 632 }
771 -
772 - public static function contains_registered_shortcode( $string ) {
773 - global $shortcode_tags;
774 -
775 - foreach ( array_keys( $shortcode_tags ) as $shortcode ) {
776 - if ( strpos( $string, "[$shortcode" ) !== false ) {
777 - return true;
778 - }
779 - }
780 -
781 - return false;
782 - }
783 -
784 - /**
785 - * Check if string is a WordPress password hash
786 - * Supports all WordPress hash formats:
787 - * - Old Portable Hash: $P$...
788 - * - Bcrypt: $2a$, $2y$...
789 - *
790 - * @param string $hash Password hash to check
791 - * @return bool
792 - */
793 - public static function is_wp_password_hash( $hash ) {
794 - if ( ! is_string( $hash ) || empty( $hash ) ) {
795 - return false;
796 - }
797 -
798 - // Old Portable Hash format: $P$[A-Za-z0-9./]{31}
799 - if ( preg_match( '/^\$P\$[A-Za-z0-9\.\/]{31}$/', $hash ) ) {
800 - return true;
801 - }
802 -
803 - // Bcrypt format: $2a$, $2x$, $2y$ followed by cost and hash
804 - if ( preg_match( '/^\$2[axy]\$\d{2}\$[A-Za-z0-9\.\/]{53}$/', $hash ) ) {
805 - return true;
806 - }
807 -
808 - return false;
809 - }
810 -
811 - public static function get_array_of_user_roles( $settings ) {
812 - if ( is_string( $settings ) ) {
813 - return '' === $settings ? array() : array( $settings );
814 - }
815 -
816 - if ( ! is_array( $settings ) ) {
817 - return array();
818 - }
819 -
820 - return $settings;
821 - }
822 -
823 - public static function get_main_user_role_by_priority( $roles ): string {
824 - if ( is_string( $roles ) ) {
825 - $roles = array( $roles );
826 - }
827 - $wp_roles_priority = array(
828 - 'editor' => 4,
829 - 'author' => 3,
830 - 'contributor' => 2,
831 - 'subscriber' => 1,
832 - );
833 -
834 - $wp_roles = array_intersect( $roles, array_keys( $wp_roles_priority ) );
835 - $custom_roles = array_diff( $roles, array_keys( $wp_roles_priority ) );
836 -
837 - usort(
838 - $wp_roles,
839 - function ( $a, $b ) use ( $wp_roles_priority ) {
840 - return ( $wp_roles_priority[ $b ] ?? 0 ) <=> ( $wp_roles_priority[ $a ] ?? 0 );
841 - }
842 - );
843 -
844 - return $wp_roles[0] ?? $custom_roles[0] ?? '';
845 - }
846 -
847 -
848 633
849 634 }