HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux sa-dev.otherchirps.net 5.15.0-139-generic #149-Ubuntu SMP Fri Apr 11 22:06:13 UTC 2025 x86_64
User: www-data (33)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wp-content/themes/kalium/includes/elementor/helpers.php
<?php

namespace Kalium\Elementor;

/**
 * Kalium WordPress Theme
 *
 * Kalium Elementor helpers class.
 *
 * @author Laborator
 * @link   https://kaliumtheme.com
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Direct access not allowed.
}

class Helpers {

	/**
	 * Get terms option.
	 *
	 * @param string $taxonomy
	 * @param array  $args
	 *
	 * @return array
	 */
	public static function get_terms_options( $taxonomy, $args = [] ) {
		$terms_options = [];

		// Args
		$args = wp_parse_args( $args, [
			'field'   => 'id',
			'default' => null,
		] );

		// Default value
		if ( ! empty( $args['default'] ) ) {
			if ( is_array( $args['default'] ) ) {
				$keys = array_keys( $args['default'] );

				$terms_options[ $keys[0] ] = $args['default'][ $keys[0] ];
			} else {
				$terms_options[''] = $args['default'];
			}
		}

		// Terms list
		$terms = get_terms( [
			'taxonomy' => $taxonomy,
		] );

		if ( ! is_wp_error( $terms ) ) {
			foreach ( $terms as $term ) {
				$option_value = 'slug' === $args['field'] ? $term->slug : $term->term_id;

				$terms_options[ $option_value ] = $term->name;
			}
		}

		return $terms_options;
	}

	/**
	 * Get post type title.
	 *
	 * @param string $post_type
	 *
	 * @return string|null
	 */
	public static function get_post_type_title( $post_type ) {
		$post_type_obj = get_post_type_object( $post_type );

		if ( is_null( $post_type_obj ) ) {
			return null;
		}

		return $post_type_obj->labels->name;
	}

	/**
	 * Get posts list options.
	 *
	 * @param array $query_args
	 *
	 * @return array|null
	 */
	public static function get_posts( $query_args = [] ) {
		$query_args = wp_parse_args( $query_args, [
			'post_status' => 'publish',
			'posts_per_page' => -1,
		] );

		$query = new \WP_Query();
		$posts = $query->query( $query_args );

		if ( ! empty( $posts ) ) {
			return wp_list_pluck( $posts, 'post_title', 'ID' );
		}
	}

	/**
	 * Get authors list options.
	 *
	 * @return array|null
	 */
	public static function get_authors() {
		$users = get_users( [
			'who'                 => 'authors',
			'has_published_posts' => true,
			'fields'              => [
				'ID',
				'display_name',
			],
		] );

		if ( ! empty( $users ) ) {
			return wp_list_pluck( $users, 'display_name', 'ID' );
		}
	}
}