first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,130 @@
<?php
/**
* Functions for Cache Utility
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Add a cache key via PUM Cache.
*
* @param $key
* @param $data
* @param string $group
*
* @return bool
*/
function pum_cache_add( $key, $data, $group = '' ) {
return PUM_Utils_Cache::add( $key, $data, $group );
}
/**
* Set a cache key via PUM Cache.
*
* @param $key
* @param $data
* @param string $group
*
* @return bool
*/
function pum_cache_set( $key, $data, $group = '' ) {
return PUM_Utils_Cache::set( $key, $data, $group );
}
/**
* Replace a cache key via PUM Cache.
*
* @param $key
* @param $data
* @param string $group
*
* @return bool
*/
function pum_cache_replace( $key, $data, $group = '' ) {
return PUM_Utils_Cache::replace( $key, $data, $group );
}
/**
* Get a cache key via PUM Cache.
*
* @param $key
* @param string $group
* @param bool $force
* @param null $found
*
* @return bool|mixed
*/
function pum_cache_get( $key, $group = '', $force = false, &$found = null ) {
return PUM_Utils_Cache::get( $key, $group, $force, $found );
}
/**
* Delete a cache key via PUM Cache.
*
* @param $key
* @param string $group
*
* @return bool
*/
function pum_cache_delete( $key, $group = '' ) {
return PUM_Utils_Cache::delete( $key, $group );
}
/**
* Delete a cache group via PUM Cache.
*
* @param string $group
*
* @return bool
*/
function pum_cache_delete_group( $group = '' ) {
return PUM_Utils_Cache::delete_group( $group );
}
/**
* Increase a numeric cache value by the offset.
*
* @param $key
* @param int $offset
* @param string $group
*
* @return bool|false|int
*/
function pum_cache_incr( $key, $offset = 1, $group = '' ) {
return PUM_Utils_Cache::incr( $key, $offset, $group );
}
/**
* Decrease a numeric cache value by the offset.
*
* @param $key
* @param int $offset
* @param string $group
*
* @return bool|false|int
*/
function pum_cache_decr( $key, $offset = 1, $group = '' ) {
return PUM_Utils_Cache::decr( $key, $offset, $group );
}
/**
* Gets the filterable timeout for a cache object by key.
*
* @param $key
*
* @return int
*/
function pum_cache_timeout( $key ) {
static $timeouts;
if ( ! isset( $timeouts ) ) {
$timeouts = apply_filters( 'pum_cache_timeouts', [] );
}
return isset( $timeouts[ $key ] ) ? $timeouts[ $key ] : 0;
}

View File

@@ -0,0 +1,52 @@
<?php
/**
* Functions for Format Utility
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* @param int $time
* @param int|null $current
*
* @return mixed
*/
function pum_human_time( $time, $current = null ) {
return PUM_Utils_Format::human_time( $time, $current );
}
/**
* @param int|float $number
* @param string $format
*
* @return int|string
*/
function pum_format_number( $number, $format = '' ) {
return PUM_Utils_Format::number( $number, $format );
}
/**
* @param int|float $number
* @param string $format U|human|human-readable
*
* @return int|string
*/
function pum_format_time( $number, $format = '' ) {
return PUM_Utils_Format::time( $number, $format );
}
/**
* Removes <p></p> around URLs
*
* @param string $content
*
* @return string
*/
function pum_unwrap_urls( $content = '' ) {
return PUM_Utils_Format::unwrap_urls( $content );
}

View File

@@ -0,0 +1,88 @@
<?php
/**
* Functions for Options Utility
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Get all forum options.
*
* @return mixed
*/
function pum_get_options() {
return PUM_Utils_Options::get_all();
}
/**
* Get a forum option.
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
function pum_get_option( $key, $default = false ) {
return PUM_Utils_Options::get( $key, $default );
}
/**
* Update a forum option.
*
* @param string $key
* @param bool $value
*
* @return bool
*/
function pum_update_option( $key = '', $value = false ) {
return PUM_Utils_Options::update( $key, $value );
}
/**
* Merge array of new option values into the existing options array.
*
* @param array $new_options
*
* @return bool
*/
function pum_merge_options( $new_options = [] ) {
return PUM_Utils_Options::merge( $new_options );
}
/**
* Delete a forum option
*
* @param string $key
*
* @return bool
*/
function pum_delete_option( $key = '' ) {
return PUM_Utils_Options::delete( $key );
}
/**
* Delete a forum option
*
* @param array $keys
*
* @return bool
*/
function pum_delete_options( $keys = [] ) {
return PUM_Utils_Options::delete( $keys );
}
/**
* Remap old option keys.
*
* @param array $remap_array
*
* @return bool
*/
function pum_remap_options( $remap_array = [] ) {
return PUM_Utils_Options::remap_keys( $remap_array );
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* Functions for Template Utility
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Get a templates part in $slug-$name.php fashion.
*
* Allows passing arguments that will be globally accessible in the templates.
*
* @param string $slug
* @param string $name
* @param array $args
*
* @return string
*/
function pum_get_template_part( $slug, $name = null, $args = null ) {
return PUM_Utils_Template::get_part( $slug, $name, $args );
}
/**
* Render a templates part in $slug-$name.php fashion.
*
* Allows passing arguments that will be globally accessible in the templates.
*
* @param string $slug
* @param string $name
* @param array $args
*/
function pum_template_part( $slug, $name = null, $args = [] ) {
echo pum_get_template_part( $slug, $name, $args );
}
/**
* Gets the rendered contents of the specified templates file.
*
* @param $template_name
* @param array $args
*
* @return string
*/
function pum_get_template( $template_name, $args = [] ) {
return PUM_Utils_Template::get( $template_name, $args );
}
/**
* Get other templates (e.g. product attributes) passing attributes and including the file.
*
* @deprecated Likely a better way @see pum_template_part()
*
* @param string $template_name Template file name with extension: file-name.php
* @param array $args (default: array())
*/
function pum_load_template( $template_name, $args = [] ) {
echo pum_get_template( $template_name, $args );
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* Functions for Upgrades Utility
*
* @package PUM
* @copyright Copyright (c) 2023, Code Atlantic LLC
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Adds an upgrade action to the completed upgrades array
*
* @since 1.7.0
*
* @see PUM_Utils_Upgrades::set_upgrade_complete
*
* @param string $upgrade_id The action to add to the competed upgrades array
*
* @return bool If the function was successfully added
*/
function pum_set_upgrade_complete( $upgrade_id = '' ) {
return PUM_Utils_Upgrades::instance()->set_upgrade_complete( $upgrade_id );
}
/**
* Get's the array of completed upgrade actions
*
* @since 1.7.0
*
* @return array The array of completed upgrades
*/
function pum_get_completed_upgrades() {
return PUM_Utils_Upgrades::instance()->get_completed_upgrades();
}
/**
* Check if the upgrade routine has been run for a specific action
*
* @since 1.7.0
*
* @param string $upgrade_id The upgrade action to check completion for
*
* @return bool If the action has been added to the completed actions array
*/
function pum_has_completed_upgrade( $upgrade_id = '' ) {
return PUM_Utils_Upgrades::instance()->has_completed_upgrade( $upgrade_id );
}
/**
* Clean up postmeta by removing all keys from the given post_id.
*
* @param int $post_id
* @param array $keys_to_delete
*/
function pum_cleanup_post_meta_keys( $post_id = 0, $keys_to_delete = [] ) {
/**
* Clean up automatically.
*/
if ( ! empty( $keys_to_delete ) ) {
global $wpdb;
$keys_to_delete = array_map( 'esc_sql', (array) $keys_to_delete );
$meta_keys = implode( "','", $keys_to_delete );
$query = $wpdb->prepare( "DELETE FROM `$wpdb->postmeta` WHERE `post_id` = %d AND `meta_key` IN ('{$meta_keys}')", $post_id );
$wpdb->query( $query );
wp_cache_delete( $post_id, 'post_meta' );
}
}