zeek / wp-utils
A collection of functions that provide utility functionality for WordPress.
Requires
- php: >=7.0
- a7/autoload: ^2
- arrilot/dotenv-php: ^1.0
- zeek/php-utils: ^2
- zeek/wp-sentry: ^1.2.3
Requires (Dev)
- 10up/wp_mock: ^0.3.0
- codacy/coverage: ^1.4
- codeception/codeception: 2.3.9
- mockery/mockery: ^1.0
- dev-master
- v6.1.2
- v6.1.1
- v6.1
- 6.0.0
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0
- 4.0.1
- 4.0.0
- 3.7.1
- 3.7
- 3.6.1
- 3.6.0
- 3.5
- 3.4.1
- 3.4.0
- 3.3
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2
- 3.1
- 3.0.1
- 3.0
- 2.12
- 2.11.2
- 2.11.1
- 2.11
- 2.10.0
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9
- 2.8
- v2.7.1
- v2.7
- v2.6
- v2.5.2
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.0
- v2.2.1
- v2.2
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- v2.1.1
- v2.1
- v2.0
- 1.6.1
- 1.6.0
- 1.5.1
- 1.5
- 1.4
- 1.3
- 1.2
- 1.1
- 1.0
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.0
- 0.7.1
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.0
- 0.1.1
- 0.1.0
- dev-wp-environment-type
- dev-sentry-update
- dev-develop
This package is auto-updated.
Last update: 2024-12-09 21:31:23 UTC
README
Utility functions that make life just a little bit easier.
Database
db_transaction( $callable, $args = [] )
Run the given callback within a database transaction, rolling back the transaction if an error occurs.
get_raw_option_value( $key )
Performs a very direct, simple query to the WordPress Options table that bypasses normal WP caching.
get_id_from_slug( $slug, $post_type = 'post', $force = false )
Performs a lookup for a post given a slug.
get_meta_key_from_meta_value()
Perform a reverse lookup for a meta key based on a meta value.
ACF
get_acf_meta_value_by_acf_key()
Use this when you know an ACF field key and a post ID, but the field is within a group.
is_acf_loadable()
(Deprecated)
Check to see if ACF is loadable and if ACF_LITE is true.
Users
generate_unique_username( $username )
Appends a counter to the given username which is incremented until there is no user with that username.
Misc
get_current_url()
Returns the current URL.
get_current_url_clean()
Returns the current URL, but without query args.
get_user_display_name( $user_id )
Easily get the user display name by the user ID.
get_env_value( $key, $filter = null )
Helper function to check for an environmental variable in a variety of places: $_ENV (for setting via .env.php files), Constant (for setting via a define() call), Filter, utilizing a passed in filter
remove_filters_for_anonymous_class( $hook_name = '', $class_name = '', $method_name = '', $priority = 10 )
Remove a filter/action from an anonymous class
add_inline_svg()
Checks if SVG file exists before grabbing its contents
get_current_datetime()
Gets a DateTime object set to WordPress's local timezone
get_site_timezone()
Get a DateTimeZone object that is set to the site's local timezone.
init_term( $slug, $taxonomy )
Checks for and returns a term by the slug. Initializes the term if it does not yet exist.
Behaviors / Filters
These must be initiated by creating the \Zeek\WP_Util\Behaviors()
class.
file_mod_allowed
By default, disable file modifications (plugin adding, deleting, theme file editing, etc). Override with an env
constant: FILE_MOD_ALLOWED
.