/** * Retrieve all of the data for the sections. * * @since 1.2.0. * * @param string $post_id The post to retrieve the data from. * @return array The combined data. */ function ttfmake_get_section_data($post_id) { $ordered_data = array(); $ids = get_post_meta($post_id, '_ttfmake-section-ids', true); $ids = !empty($ids) && is_array($ids) ? array_map('strval', $ids) : $ids; $post_meta = get_post_meta($post_id); // Temp array of hashed keys $temp_data = array(); // Any meta containing the old keys should be deleted if (is_array($post_meta)) { foreach ($post_meta as $key => $value) { // Only consider builder values if (0 === strpos($key, '_ttfmake:')) { // Get the individual pieces $temp_data[str_replace('_ttfmake:', '', $key)] = $value[0]; } } } // Create multidimensional array from postmeta $data = ttfmake_create_array_from_meta_keys($temp_data); // Reorder the data in the order specified by the section IDs if (is_array($ids)) { foreach ($ids as $id) { if (isset($data[$id])) { $ordered_data[$id] = $data[$id]; } } } /** * Filter the section data for a post. * * @since 1.2.3. * * @param array $ordered_data The array of section data. * @param int $post_id The post ID for the retrieved data. */ return apply_filters('make_get_section_data', $ordered_data, $post_id); }
/** * Convert an array with array keys that map to a multidimensional array to the array. * * Note that in 1.2.0, this function was changed to call the global function. This global function was added to * provide easier reuse of the function. In order to maintain backwards compatibility, this function is left in * place. * * @since 1.0.0. * * @param array $arr The array to convert. * @return array The converted array. */ function create_array_from_meta_keys($arr) { return ttfmake_create_array_from_meta_keys($arr); }