| Server IP : 216.238.66.20 / Your IP : 216.73.216.51 Web Server : nginx/1.30.4 System : Linux woropds 5.15.0-187-generic #197-Ubuntu SMP Fri Jul 17 19:17:01 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.2.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/sweetheart.mx/htdocs/wp-content/plugins/url-shortify/lite/includes/ |
Upload File : |
<?php
namespace KaizenCoders\URL_Shortify;
class Shortcode {
/**
* Init Shortcode
*
* @since 1.7.0
*/
public function init() {
\add_shortcode( 'shorturl', [ $this, 'render' ] );
}
/**
* Render public facing URL Shortener
*
* @since 1.7.0
*/
public function render() {
global $post;
if ( $post instanceof \WP_Post ) {
$short_link = US()->db->links->get_by_cpt_id( $post->ID );
if ( empty( $short_link ) ) {
$link_data = [
'cpt_id' => $post->ID,
'url' => get_permalink( $post->ID ),
'name' => addslashes( $post->post_title ),
'description' => addslashes( $post->post_excerpt ),
];
$created = US()->db->links->create_link( $link_data );
if ( $created ) {
$short_link = US()->db->links->get_by_cpt_id( $post->ID );
}
}
$short_url = Helper::get_short_link( $short_link['slug'] );
return sprintf( '<a href="%s" target="__blank">%s</a>', $short_url, $short_url );
}
}
}