PHPackages                             arts/utilities - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arts/utilities

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arts/utilities
==============

A comprehensive collection of utility methods for WordPress theme and plugin development, with a focus on Elementor integration.

v2.3.2(4mo ago)1727↓50%3GPL-3.0-or-laterTypeScriptPHP &gt;=8.0

Since Apr 23Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/artkrsk/arts-utilities)[ Packagist](https://packagist.org/packages/arts/utilities)[ RSS](/packages/arts-utilities/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (45)Used By (3)

ArtsUtilities
=============

[](#artsutilities)

A comprehensive collection of utility methods for WordPress theme and plugin development, with a focus on Elementor integration.

[![Latest Version on Packagist](https://camo.githubusercontent.com/ccafd2619cc08e0766807f195f89e6030cad3343d585b79bfa1cc9d2bbc67d1f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617274732f7574696c69746965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arts/utilities)[![Total Downloads](https://camo.githubusercontent.com/8933e214926ab5274b13277eba27def359ae9d25f5662c98d7ebb12233cfc743/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617274732f7574696c69746965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arts/utilities)[![License](https://camo.githubusercontent.com/00f8780f887a26ae2503e554891cc28a2476fbacac0c81d7c528a9c457dc691b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c2d2d332e302d2d6f722d2d6c617465722d626c7565)](LICENSE)[![Buy Me A Coffee](https://camo.githubusercontent.com/859815fbe285fb3eac50f46b4ad7933b69021f3b7fde8678ccdbaeeb844a769a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275792532304d6525323061253230436f666665652d6666646430303f7374796c653d666c6174266c6f676f3d6275792d6d652d612d636f66666565266c6f676f436f6c6f723d626c61636b)](https://buymeacoffee.com/artemsemkin)

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require arts/utilities
```

Basic Usage
-----------

[](#basic-usage)

The package provides a main `Utilities` class that incorporates all traits:

```
use Arts\Utilities\Utilities;

// Use any of the methods directly
$aspectRatio = Utilities::get_image_aspect_ratio($imageId);
```

Or you can use individual traits in your own classes:

```
use Arts\Utilities\Traits\Images;

class MyClass {
    use Images;

    public function myMethod() {
        $aspectRatio = self::get_image_aspect_ratio($imageId);
    }
}
```

Documentation
-------------

[](#documentation)

### Elementor Utilities

[](#elementor-utilities)

#### Controls

[](#controls)

Methods for working with Elementor controls and settings.

```
// Get thumbnail size from Elementor image control settings
$settings = $widget->get_settings_for_display();
$thumbnailSize = Utilities::get_settings_thumbnail_size($settings, $imageId, 'image');

// Get group control value
$value = Utilities::get_group_control_value($settings, 'image', 'size', 'full');
```

#### Document

[](#document)

Working with Elementor documents and document settings.

```
// Get a document option
$backgroundColor = Utilities::get_document_option('background_color', $postId, '#ffffff');

// Get an overridden document option
$headerHeight = Utilities::get_overridden_document_option('header_height', 'override_header', '100px');

// Get body styles model based on document options
$bodyStyles = Utilities::get_body_styles_model();
```

#### Kit

[](#kit)

Work with Elementor kits and global settings.

```
// Get a color value from global colors
$colorValue = Utilities::get_color_value($settings, 'button_color', '#000000');

// Get kit settings
$typographySettings = Utilities::get_kit_settings('typography_body');

// Get kit setting or theme mod
$primaryColor = Utilities::get_kit_setting_or_theme_mod('primary_color', '#default');

// Update kit settings
Utilities::update_kit_settings('primary_color', '#newcolor');
```

#### Responsive Controls

[](#responsive-controls)

Handle Elementor responsive controls and breakpoints.

```
// Get media query string for a responsive option
$mediaQuery = Utilities::get_media_query_string_for_responsive_option($element, 'show_title');

// Check if responsive option is enabled
$isEnabled = Utilities::has_responsive_enabled_option($element, 'show_title');
```

#### Theme Builder

[](#theme-builder)

Work with Elementor Theme Builder templates.

```
// Check if Theme Builder is active
$isActive = Utilities::is_theme_builder_active();

// Get the Theme Builder location ID
$locationId = Utilities::get_theme_builder_location_id();

// Check if a location has a template
$hasTemplate = Utilities::location_has_template('single');
```

#### Plugin

[](#plugin)

Check Elementor plugin status and settings.

```
// Check if Elementor is active
$isActive = Utilities::is_elementor_plugin_active();

// Check if a post is built with Elementor
$isBuiltWithElementor = Utilities::is_built_with_elementor($postId);

// Check if Elementor editor is active
$isEditorActive = Utilities::is_elementor_editor_active();
```

### WordPress Utilities

[](#wordpress-utilities)

#### ACF

[](#acf)

Work with Advanced Custom Fields.

```
// Get field value
$fieldValue = Utilities::acf_get_field('field_name', $postId);

// Check if repeater has rows
$hasRows = Utilities::acf_have_rows('repeater_field', $postId);

// Get all ACF fields for a post
$fields = Utilities::acf_get_post_fields($postId);
```

#### Blog

[](#blog)

Blog-related utilities.

```
// Output pingback link markup
Utilities::get_link_rel_pingback_markup();

// Get pagination link attributes
$attributes = Utilities::get_pagination_link_attributes(['class' => 'nav-link'], 'next');
```

#### Conditions

[](#conditions)

Check various WordPress conditions.

```
// Check if current page is an archive
$isArchive = Utilities::is_archive();
```

#### Fonts

[](#fonts)

Font-related utilities.

```
// Register custom font MIME types (add to upload_mimes filter)
add_filter('upload_mimes', [Utilities::class, 'get_fonts_mime_types']);

// Handle custom font file types (add to wp_check_filetype_and_ext filter)
add_filter('wp_check_filetype_and_ext', [Utilities::class, 'get_fonts_custom_file_extensions'], 10, 4);
```

#### Frontend

[](#frontend)

Frontend asset management utilities.

```
// Enqueue a script with dynamic loading
Utilities::enqueue_dynamic_load_script('asset', [
    'handle' => 'my-script',
    'src' => 'path/to/script.js',
    'deps' => ['jquery'],
]);

// Enqueue a stylesheet with dynamic loading
Utilities::enqueue_dynamic_load_style([
    'handle' => 'my-style',
    'src' => 'path/to/style.css',
]);

// Check if a script is eligible for dynamic loading
$isEligible = Utilities::is_script_eligible_for_dynamic_load('my-script');
```

#### Images

[](#images)

Image utilities.

```
// Get image aspect ratio
$aspectRatio = Utilities::get_image_aspect_ratio($imageId);

// Get available image sizes
$sizes = Utilities::get_available_image_sizes();
```

#### LoopedPosts

[](#loopedposts)

Work with post loops with automatic looping back to the beginning.

```
// Get previous and next posts in a loop
$prevNextPosts = Utilities::get_prev_next_posts_looped([
    'post_type' => 'post',
    'in_same_term' => true,
    'taxonomy' => 'category',
]);

// Setup and iterate through a custom loop
$posts = get_posts(['post_type' => 'product', 'posts_per_page' => 10]);
Utilities::setup_looped_posts($posts);

while (Utilities::have_looped_posts()) {
    $post = Utilities::the_looped_post();
    // Use $post data...
}

Utilities::reset_looped_posts();
```

#### Markup

[](#markup)

Generate HTML markup and handle attributes.

```
// Generate component attributes
$attrs = Utilities::get_component_attributes(
    ['class' => ['existing-class']],
    ['name' => 'MyComponent', 'hasAnimation' => true]
);

// Print HTML attributes
Utilities::print_attributes($attrs);

// Get post terms as CSS classes
$classes = Utilities::get_post_terms_classes($post);

// Validate and print HTML tag
Utilities::print_html_tag('h2');

// Add classes to the HTML element
add_filter('language_attributes', function($attributes) {
    return Utilities::add_root_html_classes($attributes, ['dark-mode', 'custom-theme']);
});
```

#### Query

[](#query)

WordPress query utilities.

```
// Get a page by title
$page = Utilities::get_page_by_title('About Us');

// Get page titles for the current context
$titles = Utilities::get_page_titles();

// Get uploaded fonts
$fonts = Utilities::get_uploaded_fonts();

// Get categories of posts
$categories = Utilities::get_posts_categories('current_page', [
    'post_type' => 'post',
    'posts_per_page' => 10,
]);

// Get post author information
$author = Utilities::get_post_author($postId);
```

#### Shortcodes

[](#shortcodes)

Custom shortcode utilities.

```
// Register current year shortcode
add_shortcode('current_year', [Utilities::class, 'get_shortcode_current_year']);
```

#### Strings

[](#strings)

String manipulation utilities.

```
// Convert camelCase to kebab-case
$kebabCase = Utilities::convert_camel_to_kebab_case('myVariableName'); // my-variable-name

// Convert camelCase to snake_case
$snakeCase = Utilities::convert_camel_to_snake_case('myVariableName'); // my_variable_name

// Convert kebab-case to camelCase
$camelCase = Utilities::convert_kebab_case_to_camel('my-kebab-string'); // myKebabString

// Get slug from string
$slug = Utilities::get_slug_from_string('My String & Stuff'); // my_string_stuff

// Get file extension from URL
$ext = Utilities::get_asset_url_file_extension('https://example.com/file.pdf'); // pdf
```

#### Taxonomies

[](#taxonomies)

Taxonomy and term utilities.

```
// Get taxonomy term names for a post
$terms = Utilities::get_taxonomy_term_names($postId, 'category');

// Get all post terms across taxonomies
$postTerms = Utilities::get_post_terms(get_object_taxonomies('post', 'objects'), $postId);

// Generate a tax query array from term IDs
$taxQuery = Utilities::get_tax_query([1, 2, 3], 'IN');

// Get term ancestors
$ancestors = Utilities::get_term_ancestors_list($termId, 'category');

// Build hierarchical taxonomy tree
$hierarchy = Utilities::get_taxonomy_hierarchy('category');

// Get a term by field
$term = Utilities::get_term_by('slug', 'news', 'category');
```

#### Theme

[](#theme)

Theme utilities.

```
// Get parent theme version
$version = Utilities::get_parent_theme_version();
```

#### URL

[](#url)

URL utilities.

```
// Check if referer is from same domain
$isSameDomain = Utilities::is_referer_from_same_domain();

// Get license arguments URL for EDD
$url = Utilities::get_license_args_url('https://example.com/api', 'license_key_option');
```

#### WooCommerce

[](#woocommerce)

WooCommerce utilities.

```
// Check if current page is shop
$isShop = Utilities::is_shop();

// Check if current page is WooCommerce
$isWooCommerce = Utilities::is_woocommerce();

// Get WooCommerce URLs
$urls = Utilities::get_woocommerce_urls();

// Get WooCommerce page title
$title = Utilities::get_woocommerce_page_title();

// Get a product
$product = Utilities::get_product($productId);

// Check if product is in stock
$inStock = Utilities::is_product_in_stock($productId);

// Get cart contents
$cartContents = Utilities::get_cart_contents();

// Get cart total
$total = Utilities::get_cart_total();
```

License
-------

[](#license)

GPL-3.0-or-later - Compatible with WordPress. Please see [License File](LICENSE) for more information.

This library is licensed under GPL-3.0-or-later to ensure compatibility with WordPress and GPL-licensed plugins.

💖 Support
---------

[](#-support)

If you find this package useful, consider buying me a coffee:

[![Buy Me A Coffee](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://buymeacoffee.com/artemsemkin)

---

Made with ❤️ by [Artem Semkin](https://artemsemkin.com)

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance82

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

42

Last Release

126d ago

Major Versions

v1.1.12 → v2.0.02025-12-18

PHP version history (2 changes)v1.0.0PHP &gt;=7.2

v2.2.3PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7bea30c2234cb7a9564df323f88f993da491615955ed3fb66a42db98c12d0d15?d=identicon)[artkrsk](/maintainers/artkrsk)

---

Top Contributors

[![artkrsk](https://avatars.githubusercontent.com/u/15735987?v=4)](https://github.com/artkrsk "artkrsk (196 commits)")

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/arts-utilities/health.svg)

```
[![Health](https://phpackages.com/badges/arts-utilities/health.svg)](https://phpackages.com/packages/arts-utilities)
```

###  Alternatives

[cweagans/composer-patches

Provides a way to patch Composer packages.

1.7k94.2M762](/packages/cweagans-composer-patches)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
