PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.4
JetFormBuilder — Dynamic Blocks Form Builder v3.6.4
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 All 130 releases
jetformbuilder / modules / user-journey / tools.php
tools.php
59 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Modules\User_Journey;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 /**
12 * Tools for User Journey Module
13 *
14 * This file provides utility functions for the User Journey module.
15 */
16 class Tools {
17 /**
18 * Retrieves WordPress page data by URL.
19 *
20 * @param string $url The URL to retrieve data for.
21 *
22 * @return array|false An array of page data or false if not found.
23 */
24 public static function get_wp_page_data_by_url( string $url ) {
25 if ( function_exists( 'wc_get_page_id' ) && function_exists( 'get_permalink' ) ) {
26 $shop_page_id = wc_get_page_id( 'shop' );
27 $shop_url = get_permalink( $shop_page_id );
28 $shop_url_path = wp_parse_url( $shop_url, PHP_URL_PATH );
29
30 if ( $shop_url_path === $url ) {
31 return array(
32 'ID' => $shop_page_id,
33 'title' => get_the_title( $shop_page_id ),
34 'permalink' => $shop_url,
35 );
36 }
37 }
38
39 if ( '/' === $url ) {
40 $post_id = get_option( 'page_on_front' );
41 } else {
42 $post_id = url_to_postid( $url );
43 }
44
45 if ( ! $post_id ) {
46 return false;
47 }
48
49 $title = get_the_title( $post_id );
50 $permalink = get_permalink( $post_id );
51
52 return array(
53 'ID' => $post_id,
54 'title' => $title,
55 'permalink' => $permalink,
56 );
57 }
58 }
59