_field || !in_array($ref_field['type'], ['reference'], true)) { continue; } $ref_post_parent = $ref_field['ref_collection']; $nested_matched_ids = self::get_matched_post_ids_recursive($ref_post_parent, $query, $depth + 1, $max_depth); if (!empty($nested_matched_ids)) { $meta_key = ContentManagerHelper::get_child_post_meta_key_using_field_id( $post_parent, $ref_field['id'] ); $ids = implode( ',', array_map( 'intval', $nested_matched_ids ) ); $ref_post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM {$wpdb->prefix}kirki_cm_reference WHERE field_meta_key = %s AND ref_post_id IN ($ids)", $meta_key ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared $matched_post_ids = array_merge($matched_post_ids, $ref_post_ids); } } return array_unique(array_map('intval', $matched_post_ids)); } public static function get_referenced_post_ids($post_parent, $post) { global $wpdb; $allData = ContentManagerHelper::get_post_type_custom_field_keys($post_parent); $post_ids = []; foreach ($allData as $data) { if ($data && in_array($data['type'], ['reference', 'multi-reference'], true)) { $meta_key = 'kirki_cm_field_' . $post_parent . '_' . $data['id']; $results = $wpdb->get_results( $wpdb->prepare( "SELECT ref_post_id FROM {$wpdb->prefix}kirki_cm_reference WHERE field_meta_key = %s AND post_id = %d", $meta_key, $post->ID ), ARRAY_A ); foreach ($results as $id) { $related_posts = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM {$wpdb->prefix}kirki_cm_reference WHERE field_meta_key = %s AND ref_post_id = %d", $meta_key, (int) $id['ref_post_id'] ), ARRAY_A ); foreach ($related_posts as $related) { $related_id = (int) $related['post_id']; if ($related_id !== (int) $post->ID) { $post_ids[] = $related_id; } } } } } $post_ids = array_values(array_unique($post_ids)); return !empty($post_ids) ? $post_ids : [0]; } public static function get_terms($params) { $terms_array = []; $current_page = isset($params['current_page']) ? (int)$params['current_page'] : 1; $item_per_page = isset($params['item_per_page']) ? (int)$params['item_per_page'] : 3; $offset = isset($params['offset']) ? (int)$params['offset'] : 0; if (!empty($params['inherit'])) { $terms_array = get_the_terms($params['post_parent'], $params['taxonomy']); if (is_array($terms_array)) { // Convert WP_Term objects to arrays only if needed $terms_array = array_map(function($term) { return is_object($term) && method_exists($term, 'to_array') ? $term->to_array() : (array)$term; }, $terms_array); $calculated_offset = (($current_page - 1) * $item_per_page) + $offset; $terms_array = array_slice($terms_array, $calculated_offset, $item_per_page); } else { $terms_array = []; } } else { $params['offset'] = (($current_page - 1) * $item_per_page) + $offset; $params['number'] = $item_per_page; $terms_array = get_terms($params); if (is_array($terms_array)) { foreach ($terms_array as &$item) { if (is_object($item) && method_exists($item, 'to_array')) { $item = $item->to_array(); } elseif (is_object($item)) { $item = (array)$item; } } } else { $terms_array = []; } } // Count total terms $total_terms = 0; if (!empty($params['inherit'])) { $t = get_the_terms($params['post_parent'], $params['taxonomy']); if (is_array($t)) { $total_terms = count($t); } else { $total_terms = wp_count_terms($params['taxonomy'], array_merge($params, ['offset' => 0, 'number' => 0])); } } else { $total_terms = wp_count_terms($params['taxonomy'], array_merge($params, ['offset' => 0, 'number' => 0])); } $total_pages = ($item_per_page > 0) ? ceil($total_terms / $item_per_page) : 1; $prev_page = ($current_page > 1) ? $current_page - 1 : null; $next_page = ($current_page < $total_pages) ? $current_page + 1 : null; return [ 'data' => $terms_array, 'pagination' => [ 'per_page' => $item_per_page, 'current_page' => $current_page, 'total_pages' => $total_pages, 'total_count' => $total_terms, 'previous' => $prev_page, 'next' => $next_page, ], ]; } public static function buildTaxonomyForRelatedPosts(\WP_Post $post) { $taxonomies = get_object_taxonomies( $post->post_type ); $taxQuery = [ 'relation' => 'OR', ]; foreach ($taxonomies as $taxonomy) { $taxQuery[] = [ 'taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => array_filter(wp_get_object_terms($post->ID, $taxonomy, ['fields' => 'slugs']), function ($termSlug) { return strtolower($termSlug) !== 'uncategorized'; }), ]; } return $taxQuery; } /** * Get dynamic collectiond data * * @param object $params query object. * * @return array post array */ public static function get_comments( $params ) { $parent = (int)($params['parent'] ?? 0); $post_id = (int)($params['post_id'] ?? 0); $type = ($params['type'] ?? 'comment'); $sorting = isset( $params['sorting'] ) ? $params['sorting'] : null; $filters = isset( $params['filters'] ) ? $params['filters'] : null; // add new $current_page = isset( $params['current_page'] ) ? $params['current_page'] : 1; $item_per_page = isset( $params['item_per_page'] ) ? $params['item_per_page'] : 3; $offset = isset( $params['offset'] ) ? $params['offset'] : 0; // Calculate the offset $offset_cal = ($current_page - 1) * $item_per_page + $offset; $args = array( 'parent' => $parent, 'post_id' => $post_id, 'type' => $type, 'number' => $item_per_page, 'paged' => $current_page, 'offset' => $offset_cal, 'count' => false ); if ( isset( $filters ) && is_array( $filters ) ) { foreach ( $filters as $filter_item ) { $field_name = isset( $filter_item['id'] ) ? $filter_item['id'] : ''; if(!$field_name){ continue; } switch($field_name) { case 'comment_date': case 'comment_date_gmt':{ /** * $filter_item['items'] max contain one array. * in array may contain start-date, end-date * Like: [{"start-date": "2020-01-01","end-date": "2020-01-02"}] */ if(isset($filter_item['items'], $filter_item['items'][0])) { $items = $filter_item['items']; $item = $items[0]; // Get first item in array. $date_query = array('column' => $field_name); $date_query['inclusive'] = true; if (!empty($item['start-date'])) { $date_query['after'] = $item['start-date']; } if (!empty($item['end-date'])) { $date_query['before'] = $item['end-date']; } $args['date_query'] = $date_query; } break; } case 'comment_author': { $items = $filter_item['items']; // $items['items'] max contain one array. foreach($items as $item) { if ( isset( $item['condition'], $item['values'] ) && is_array( $item['values'] ) ) { if ( $item['condition'] === 'in' ) { $args['author__in'] = $item['values']; } if ( $item['condition'] === 'not-in' ) { $args['author__not_in'] = $item['values']; } } } break; } case 'comment_approved': { $items = $filter_item['items']; // $items['items'] max contain one array. foreach($items as $item) { if ( isset( $item['condition'], $item['values'] ) && is_array( $item['values'] ) ) { if ( $item['condition'] === 'in' ) { $args['status'] = $item['values']; } } } } } } } if(isset($sorting)){ // Set the sort order (ASC/DESC) if ( isset( $sorting['order'] ) ) { $args['order'] = $sorting['order']; } if ( isset( $sorting['orderby'] ) && !empty($sorting['orderby']) ) { $args['orderby'] = $sorting['orderby']; } } $comments = get_comments($args); unset($args['number']); unset($args['paged']); if (is_array($comments)) { foreach($comments as &$comment) { $comment = (object)(array)$comment; $author_posts_page_link = $comment->comment_author_url; if (!$author_posts_page_link) { $author_posts_page_link = \get_author_posts_url($comment->user_id); } $comment->author_profile_picture = array( 'src' => get_avatar_url( $comment->user_id ) ); $comment->author_posts_page_link = $author_posts_page_link; } } // Get total comments count $total_comments = get_comments( array_merge( $args, array( 'count' => true ) ) ) ; $total_comments = $total_comments - $offset; // Calculate total pages $total_pages = ceil( $total_comments / $item_per_page ); // Calculate previous and next pages $prev_page = ( $current_page > 1 ) ? $current_page - 1 : null; $next_page = ( $current_page < $total_pages ) ? $current_page + 1 : null; // return $comments; return array( 'data' => $comments, // Raw comments data 'pagination' => array( 'per_page' => $item_per_page, 'current_page' => $current_page, 'total_pages' => $total_pages, 'total_count' => $total_comments, 'previous' => $prev_page, 'next' => $next_page, ), ); } /** * Remove all default assets * * @return void */ public static function remove_wp_assets() { /* // Remove all WordPress actions // remove_all_actions('wp_head'); // remove_all_actions('wp_print_styles'); // remove_all_actions('wp_print_head_scripts'); // remove_all_actions('wp_footer'); // // Handle `wp_head` // add_action('wp_head', 'wp_enqueue_scripts', 1); // add_action('wp_head', 'wp_print_styles', 8); // add_action('wp_head', 'wp_print_head_scripts', 9); // add_action('wp_head', 'wp_site_icon'); // // Handle `wp_footer` // add_action('wp_footer', 'wp_print_footer_scripts', 20); // // Handle `wp_enqueue_scripts` // remove_all_actions('wp_enqueue_scripts'); // // Also remove all scripts hooked into after_wp_tiny_mce. // remove_all_actions('after_wp_tiny_mce'); */ // remove admin-bar. add_filter( 'show_admin_bar', '__return_false', PHP_INT_MAX ); } /** * Get server protocol * currently not in use * * @return string protocol name. */ public static function get_protocol() { $protocol = isset( $_SERVER['HTTPS'] ) ? 'https' : 'http'; return $protocol; } /** * Check if the current user has specific role ($role) * * @param string $role The role to check. * @return boolean */ public static function user_is( $role ) { $user = wp_get_current_user(); $roles = $user->roles; return is_array( $roles ) && count( $roles ) && in_array( $role, $roles, true ) ? true : false; } /** * Check if the user has access to edit/create specific/all post * * @param int $post_id post id. * @return boolean */ public static function user_has_post_edit_access() { return self::has_access( array( KIRKI_ACCESS_LEVELS['FULL_ACCESS'], KIRKI_ACCESS_LEVELS['CONTENT_ACCESS'], ) ); } /** * Check if the user has access to editor * * @return boolean */ public static function user_has_editor_access() { if(isset($_GET['editor-preview-token'])){ //phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $editor_preview_token = self::sanitize_text( isset( $_GET['editor-preview-token'] ) ? $_GET['editor-preview-token'] : '' ); return self::is_post_editor_preview_token_valid($editor_preview_token); } return self::has_access( array( KIRKI_ACCESS_LEVELS['FULL_ACCESS'], KIRKI_ACCESS_LEVELS['CONTENT_ACCESS'], KIRKI_ACCESS_LEVELS['VIEW_ACCESS'], ) ); } public static function getallheaders() { $headers = []; foreach ($_SERVER as $name => $value) { if (strpos($name, 'HTTP_') === 0) { $key = substr($name, 5); } elseif (in_array($name, ['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'])) { $key = $name; } else { continue; } // Convert HEADER_NAME → Header-Name $key = str_replace('_', ' ', strtolower($key)); $key = ucwords($key); $key = str_replace(' ', '-', $key); $headers[$key] = $value; } return $headers; } public static function is_api_call_from_editor_preview(){ // Check the Editor-Preview-Token header $headers = self::getallheaders(); $editor_preview_token = isset($headers['Editor-Preview-Token']) ? $headers['Editor-Preview-Token'] : null; if($editor_preview_token){ return true; } return false; } public static function is_api_header_post_editor_preview_token_valid(){ // Check the Editor-Preview-Token header $headers = self::getallheaders(); $editor_preview_token = isset($headers['Editor-Preview-Token']) ? $headers['Editor-Preview-Token'] : null; if(HelperFunctions::is_post_editor_preview_token_valid( $editor_preview_token)){ return true; } return false; } public static function is_post_editor_preview_token_valid($token){ $status = HelperFunctions::get_global_data_using_key('kirki_editor_read_only_access_status'); if($status){ $kirki_editor_read_only_access_token = HelperFunctions::get_global_data_using_key('kirki_editor_read_only_access_token'); if($kirki_editor_read_only_access_token && $kirki_editor_read_only_access_token === $token){ return true; } } return false; } /** * Check if the current user has specific access * * @param string|string[] $access_level The access level to check access. */ public static function has_access( $access_level ) { $user = wp_get_current_user(); $roles = $user->roles; $has_access = false; if ( is_array( $access_level ) ) { foreach ( $roles as $role ) { $access = get_option('kirki_' . $role ); if ( ! empty( $access ) && in_array( $access, $access_level, true ) ) { $has_access = true; break; } } } elseif ( is_string( $access_level ) ) { foreach ( $roles as $role ) { $access = get_option('kirki_' . $role ); if ( ! empty( $access ) && $access === $access_level ) { $has_access = true; break; } } } return $has_access; } /** * This method will collect license info from kirki.com * * @param string $license_key user license key. * @return array license info. */ public static function get_my_license_info( $license_key ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $info = self::http_get( KIRKI_CORE_PLUGIN_URL . '/?license_key=' . $license_key . '&host=' . rawurlencode( self::sanitize_text( isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : null ) ) ); $info = json_decode( $info, true ); if ( $info && isset( $info['success'] ) ) { return $info['data']; } else { return array( 'key' => $license_key ); } } /** * HTTP get * * @param string $url api endpoint url. * @return string|bool response. */ public static function http_get( $url, $args = array() ) { try { $response = wp_remote_get( $url, $args ); if ( ( !is_wp_error($response)) && (200 === wp_remote_retrieve_response_code( $response ) ) ) { $responseBody = $response['body']; return $responseBody; } return false; } catch( \Exception $ex ) { return false; } } /** * HTTP post * * @param string $url api endpoint url. * @param array $options options. * @return array|WP_Error response. */ public static function http_post( $url, $options ) { $res = wp_remote_post( $url, $options ); return $res; } /** * Text domain load hooks * * @param string $handle kirki handle. * @return void */ public static function load_script_text_domain( $handle ) { wp_set_script_translations( $handle, 'kirki', KIRKI_ROOT_PATH . 'languages/' ); } /** * Delete kirki related meta if a post is deleted. * * @param int $post_id post id. * @return void */ public static function delete_post_with_meta_key( $post_id ) { delete_post_meta( $post_id, KIRKI_META_NAME_FOR_USED_STYLE_BLOCK_IDS ); delete_post_meta( $post_id, KIRKI_META_NAME_FOR_USED_STYLE_BLOCK_IDS . '_random' ); delete_post_meta( $post_id, 'kirki' ); delete_post_meta( $post_id, KIRKI_META_NAME_FOR_POST_EDITOR_MODE ); delete_post_meta( $post_id, KIRKI_GLOBAL_STYLE_BLOCK_META_KEY ); delete_post_meta( $post_id, KIRKI_GLOBAL_STYLE_BLOCK_META_KEY . '_random' ); } /** * Get the query string for the media type * * @param string $type media type. * @return string The query string. * @example HelperFunctions::get_media_type_query_string('image') => 'image/jpeg, image/png, image/gif' */ public static function get_media_type_query_string( $type ) { return implode( ', ', array_map( function ( $v ) { return "'" . $v . "'"; }, KIRKI_SUPPORTED_MEDIA_TYPES[ $type ] ) ); } /** * This is for component configuration/object javascript variable. * * @return string script tag */ public static function get_empty_variables() { $s = "'; return $s; } /** * Check kirki and kirki pro is active or not * * @param string $plugin_main_file plugin main PHP file name. * @return boolean */ public static function is_plugin_activate( $plugin_main_file ) { if ( in_array( $plugin_main_file, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { // plugin is activated. return true; } return false; } /** * This function will verify nonce * ACT like API calls auth middleware * * @param string $action ajax action name. * * @return void */ public static function verify_nonce( $action = -1 ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $nonce = self::sanitize_text( isset( $_SERVER['HTTP_X_WP_NONCE'] ) ? $_SERVER['HTTP_X_WP_NONCE'] : null ); if ( ! wp_verify_nonce( $nonce, $action ) ) { wp_send_json_error( 'Not authorized' ); exit; } } /** * Unslash and sanitize text * * @param string $v text. * @return string sanitized text. */ public static function sanitize_text( $v ) { return sanitize_text_field( wp_unslash( $v ) ); } /** * Get current WordPress session ID. * This method generates a unique session ID if none exists. * * @return string Session ID. */ public static function get_session_id() { // First, check if a session ID is already stored in the static variable. if (self::$global_session_id) { return self::$global_session_id; } // Check if a session ID exists in a cookie. if (isset($_COOKIE['kirki_session_id'])) { self::$global_session_id = sanitize_text_field($_COOKIE['kirki_session_id']); return self::$global_session_id; } // Generate a new session ID. self::$global_session_id = wp_generate_uuid4(); // Set the session ID in a cookie. setcookie('kirki_session_id', self::$global_session_id, time() + (DAY_IN_SECONDS * 7), COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true); return self::$global_session_id; } /** * Get session data by key using WordPress transients. * * @param string $key The key of the session data to retrieve. * @return mixed|null The session data if found, null otherwise. */ public static function get_session_data($key) { // Get the current session ID. $session_id = self::get_session_id(); // Retrieve the session data. $session_data = get_transient('kirki_session_' . $session_id); if (isset($session_data[$key])) { return $session_data[$key]; } return null; } /** * Add or update session data using WordPress transients. * * @param string $key The key of the session data. * @param mixed $value The value of the session data. * @return void */ public static function set_session_data($key, $value) { // Get the current session ID. $session_id = self::get_session_id(); // Retrieve existing session data. $session_data = get_transient('kirki_session_' . $session_id) ?: array(); // Update the session data. $session_data[$key] = $value; // Save the updated session data with a 24-hour expiration time. set_transient('kirki_session_' . $session_id, $session_data, DAY_IN_SECONDS); } /** * Delete session data by key using WordPress transients. * * @param string $key The key of the session data to delete. * @return void */ public static function delete_session_data($key) { // Get the current session ID. $session_id = self::get_session_id(); // Retrieve existing session data. $session_data = get_transient('kirki_session_' . $session_id); if (isset($session_data[$key])) { unset($session_data[$key]); // Save the updated session data or delete the transient if empty. if (!empty($session_data)) { set_transient('kirki_session_' . $session_id, $session_data, DAY_IN_SECONDS); } else { delete_transient('kirki_session_' . $session_id); } } } /** * Is Pro user checking function. * * @return bool */ public static function is_pro_user() { $common_data = WpAdmin::get_common_data( true ); $bool= isset( $common_data['license_key']['valid'] ) && boolval( $common_data['license_key']['valid'] ) === true; return $bool; } /** * Store Error log to kirki server * * @param string $error_text the error text created in PHP. * * @return void */ public static function store_error_log( $error_text ) { $kirki_version = KIRKI_VERSION; self::http_get( KIRKI_CORE_PLUGIN_URL . "?log_data=error&version=$kirki_version&error_type=php&error_text=$error_text" ); } /** * Get all view port lists * * @return string viewports list variable in script markup. */ public static function get_view_port_lists() { $s = ''; $list = UserData::get_view_port_list(); if ( $list ) { $s .= "'; } return $s; } /** * Get all css variables * * @return string variables in script markup. */ public static function get_kirki_css_variables_data() { $s = ''; $variableData = UserData::get_kirki_variable_data(); if ( $variableData ) { $s .= "'; } return $s; } /** * Get smooth scroll script * * @return string script markup. */ public static function get_smooth_scroll_script() { $common_data = WpAdmin::get_common_data(true); $smooth_scroll_enabled = isset($common_data['smooth_scroll'], $common_data['smooth_scroll']['enabled']) ? $common_data['smooth_scroll']['enabled'] : false; $smooth_scroll_value = isset($common_data['smooth_scroll'], $common_data['smooth_scroll']['value']) ? $common_data['smooth_scroll']['value'] : 1; /** * User value 1 to 200 * * Min duration 1s * Max duration 12s * */ $duration = ceil(($smooth_scroll_value / 200) * 12); $s = ''; if ($smooth_scroll_enabled) { $s .= "'; } return $s; } /** * Format the date with date format * * @return string */ public static function format_date($date, $format) { if ($date && $format) { $date_formats_arr = [ 'DD/MM/YYYY' => 'd/m/Y', 'DD-MM-YYYY' => 'd-m-Y', 'DD.MM.YYYY' => 'd.m.Y', 'MM/DD/YYYY' => 'm/d/Y', 'MM-DD-YYYY' => 'm-d-Y', 'MM.DD.YYYY' => 'm.d.Y', 'MMMM DD, YYYY' => 'F j, Y', 'MMM DD, YYYY' => 'M j, Y', 'YYYY-MM-DD' => 'Y-m-d', 'YYYY/MM/DD' => 'Y/m/d', 'YY.MM.DD' => 'y.m.d', 'YY/MM/DD' => 'y/m/d', 'YY-MM-DD' => 'y-m-d', ]; $timestamp = strtotime($date); if ($timestamp === false) { return $date; // fallback (avoid fatal) } $datetime = (new \DateTime())->setTimestamp($timestamp); return $datetime->format($date_formats_arr[$format] ?? $format); } return $date; } /** * Format the time with time format * * @return string */ public static function convert_time_format($timeString, $format = 'h:i a') { $dateTime = null; try { $dateTime = new \DateTime($timeString); if ($dateTime && $timeString) { return $dateTime->format($format); } } catch (\Exception $e) { // if timeString is an invalid time format $parts = explode(' ', $timeString); if (count($parts) > 1) { // Remove the last part (am/pm) $time_value = $parts[0]; try { $dateTime = new \DateTime($time_value); if ($dateTime && $timeString) { return $dateTime->format($format); } } catch (\Exception $e2) { return $timeString; } } return $timeString; } return $timeString; } /** * Get single post if has a kirki type post * * @return object|bool */ public static function get_last_edited_kirki_editor_type_page(){ $args = array( 'post_type' => 'page', // Change to 'post' if you want to search for posts 'post_status' => ['publish', 'draft'], 'numberposts' => 1, // Number of results to retrieve (change as needed) 'meta_key' => 'kirki_editor_mode', 'meta_value' => 'kirki', 'orderby' => 'modified', // Order by post date 'order' => 'DESC', // Sort in descending order ); $pages = get_posts($args); if(count($pages) > 0){ return $pages[0]; } return false; } public static function get_kirki_version_from_db() { $version = wp_cache_get('kirki_version', 'kirki'); if (false === $version) { $version = get_option('kirki_version', ''); if ( !empty($version) ) { wp_cache_set('kirki_version', $version, 'kirki'); } } return $version; } public static function set_kirki_version_in_db() { $version = self::get_kirki_version_from_db(); if($version && version_compare($version, KIRKI_VERSION, '==')) { // No need to update the version if it's already equal to the current version. return; } update_option('kirki_version', KIRKI_VERSION, false); wp_cache_set('kirki_version', KIRKI_VERSION, 'kirki'); } public static function accepted_file_types_by_plugin($accepted_media_types = KIRKI_SUPPORTED_MEDIA_TYPES) { $result = array(); foreach ($accepted_media_types as $value) { if (is_array($value)) { $result = array_merge($result, self::accepted_file_types_by_plugin($value)); } else { $result[] = $value; } } return $result; } public static function content_manager_link_filter($dynamic_content = array(), $href="#") { $current_post = get_post(self::get_post_id_if_possible_from_url()); if ($current_post->post_type === KIRKI_CONTENT_MANAGER_PREFIX) { $fields = ContentManagerHelper::get_post_type_custom_field_keys($current_post->post_parent); if (isset($fields[$dynamic_content['value']]) && is_array($fields[$dynamic_content['value']])) { if ('email' === $fields[$dynamic_content['value']]['type']) { $href = "mailto:$href"; } else if ('phone' === $fields[$dynamic_content['value']]['type']) { $href = "tel:$href"; } } } return $href; } public static function check_string_has_this_tags($string, $tag) { // Check if the string contains either a
tag or an